tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

field_trials_view.h (1906B)


      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 <memory>
     14 #include <string>
     15 
     16 #include "absl/strings/match.h"
     17 #include "absl/strings/string_view.h"
     18 #include "rtc_base/checks.h"
     19 #include "rtc_base/system/rtc_export.h"
     20 
     21 namespace webrtc {
     22 
     23 // An interface that provides the means to access field trials.
     24 //
     25 // A FieldTrialsView is guaranteed to be immutable,
     26 //
     27 // Note that there are no guarantess that the meaning of a particular key-value
     28 // mapping will be preserved over time and no announcements will be made if they
     29 // are changed. It's up to the library user to ensure that the behavior does not
     30 // break.
     31 class RTC_EXPORT FieldTrialsView {
     32 public:
     33  virtual ~FieldTrialsView() = default;
     34 
     35  // Returns the configured value for `key` or an empty string if the field
     36  // trial isn't configured.
     37  virtual std::string Lookup(absl::string_view key) const = 0;
     38 
     39  bool IsEnabled(absl::string_view key) const {
     40    return absl::StartsWith(Lookup(key), "Enabled");
     41  }
     42 
     43  bool IsDisabled(absl::string_view key) const {
     44    return absl::StartsWith(Lookup(key), "Disabled");
     45  }
     46 
     47  // Create a copy of this view.
     48  //
     49  // This method can't be pure virtual, due to downstream projects
     50  // but that is fine since they won't use the method...if they
     51  // implement their own FieldTrialsView.
     52  virtual std::unique_ptr<FieldTrialsView> CreateCopy() const {
     53    RTC_CHECK_NOTREACHED();
     54    return nullptr;
     55  }
     56 };
     57 
     58 }  // namespace webrtc
     59 
     60 #endif  // API_FIELD_TRIALS_VIEW_H_