blob: 822e78c09673a2b657e33fd18d7bbe6bd54e2590 [file] [log] [blame]
Jonas Oreland128c4dc2022-03-30 07:57:48 +02001/*
2 * Copyright (c) 2022 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef API_FIELD_TRIALS_H_
12#define API_FIELD_TRIALS_H_
13
14#include <string>
15
16#include "absl/strings/string_view.h"
17#include "api/field_trials_view.h"
18#include "rtc_base/containers/flat_map.h"
19
20namespace webrtc {
21
22// The FieldTrials class is used to inject field trials into webrtc.
23//
24// Field trials allow webrtc clients (such as Chromium) to turn on feature code
25// in binaries out in the field and gather information with that.
26//
27// They are designed to be easy to use with Chromium field trials and to speed
28// up developers by reducing the need to wire up APIs to control whether a
29// feature is on/off.
30//
31// The field trials are injected into objects that use them at creation time.
32//
33// NOTE: Creating multiple FieldTrials-object is currently prohibited
34// until we remove the global string (TODO(bugs.webrtc.org/10335))
35class FieldTrials : public FieldTrialsView {
36 public:
37 explicit FieldTrials(const std::string& s);
38 ~FieldTrials();
39
40 std::string Lookup(absl::string_view key) const override;
41
42 private:
43 const std::string field_trial_string_;
44 const char* const previous_field_trial_string_;
45 const flat_map<std::string, std::string> key_value_map_;
46};
47
48} // namespace webrtc
49
50#endif // API_FIELD_TRIALS_H_