| 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/match.h" |
| 16 | #include "absl/strings/string_view.h" |
| 17 | #include "rtc_base/system/rtc_export.h" |
| 18 |
| 19 | namespace webrtc { |
| 20 |
| 21 | // An interface that provides the means to access field trials. |
| 22 | // |
| 23 | // Note that there are no guarantess that the meaning of a particular key-value |
| 24 | // mapping will be preserved over time and no announcements will be made if they |
| 25 | // are changed. It's up to the library user to ensure that the behavior does not |
| 26 | // break. |
| 27 | class RTC_EXPORT FieldTrialsView { |
| 28 | public: |
| 29 | virtual ~FieldTrialsView() = default; |
| 30 |
| 31 | // Returns the configured value for `key` or an empty string if the field |
| 32 | // trial isn't configured. |
| 33 | virtual std::string Lookup(absl::string_view key) const = 0; |
| 34 |
| 35 | bool IsEnabled(absl::string_view key) const { |
| 36 | return absl::StartsWith(Lookup(key), "Enabled"); |
| 37 | } |
| 38 |
| 39 | bool IsDisabled(absl::string_view key) const { |
| 40 | return absl::StartsWith(Lookup(key), "Disabled"); |
| 41 | } |
| 42 | }; |
| 43 |
| 44 | } // namespace webrtc |
| 45 |
| 46 | #endif // API_FIELD_TRIALS_VIEW_H_ |
| 47 |