blob: 45e6f7899bd78a1fdf3a8ea5cdef9ef40c74c9f2 [file] [log] [blame]
Jonas Orelande62c2f22022-03-29 11:04:48 +02001/*
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
18namespace webrtc {
19
Emil Lundmark1c8103d2022-09-21 15:20:22 +020020// 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.
Jonas Orelande62c2f22022-03-29 11:04:48 +020026class RTC_EXPORT FieldTrialsView {
27 public:
28 virtual ~FieldTrialsView() = default;
Emil Lundmark1c8103d2022-09-21 15:20:22 +020029
30 // Returns the configured value for `key` or an empty string if the field
31 // trial isn't configured.
Jonas Orelande62c2f22022-03-29 11:04:48 +020032 virtual std::string Lookup(absl::string_view key) const = 0;
33
34 bool IsEnabled(absl::string_view key) const {
35 return Lookup(key).find("Enabled") == 0;
36 }
37
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
45typedef FieldTrialsView WebRtcKeyValueConfig;
46
47} // namespace webrtc
48
49#endif // API_FIELD_TRIALS_VIEW_H_