xref: /aosp_15_r20/external/webrtc/api/field_trials_view.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright 2019 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 #ifndef API_FIELD_TRIALS_VIEW_H_
11 #define API_FIELD_TRIALS_VIEW_H_
12 
13 #include <string>
14 
15 #include "absl/strings/string_view.h"
16 #include "rtc_base/system/rtc_export.h"
17 
18 namespace webrtc {
19 
20 // An interface that provides the means to access field trials.
21 //
22 // Note that there are no guarantess that the meaning of a particular key-value
23 // mapping will be preserved over time and no announcements will be made if they
24 // are changed. It's up to the library user to ensure that the behavior does not
25 // break.
26 class RTC_EXPORT FieldTrialsView {
27  public:
28   virtual ~FieldTrialsView() = default;
29 
30   // Returns the configured value for `key` or an empty string if the field
31   // trial isn't configured.
32   virtual std::string Lookup(absl::string_view key) const = 0;
33 
IsEnabled(absl::string_view key)34   bool IsEnabled(absl::string_view key) const {
35     return Lookup(key).find("Enabled") == 0;
36   }
37 
IsDisabled(absl::string_view key)38   bool IsDisabled(absl::string_view key) const {
39     return Lookup(key).find("Disabled") == 0;
40   }
41 };
42 
43 // TODO(bugs.webrtc.org/10335): Remove once all migrated to
44 // api/field_trials_view.h
45 typedef FieldTrialsView WebRtcKeyValueConfig;
46 
47 }  // namespace webrtc
48 
49 #endif  // API_FIELD_TRIALS_VIEW_H_
50