• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "rtc_base/experiments/field_trial_list.h"
11 
12 namespace webrtc {
13 
FieldTrialListBase(std::string key)14 FieldTrialListBase::FieldTrialListBase(std::string key)
15     : FieldTrialParameterInterface(key),
16       failed_(false),
17       parse_got_called_(false) {}
18 
Failed() const19 bool FieldTrialListBase::Failed() const {
20   return failed_;
21 }
Used() const22 bool FieldTrialListBase::Used() const {
23   return parse_got_called_;
24 }
25 
Length()26 int FieldTrialListWrapper::Length() {
27   return GetList()->Size();
28 }
Failed()29 bool FieldTrialListWrapper::Failed() {
30   return GetList()->Failed();
31 }
Used()32 bool FieldTrialListWrapper::Used() {
33   return GetList()->Used();
34 }
35 
Parse(absl::optional<std::string> str_value)36 bool FieldTrialStructListBase::Parse(absl::optional<std::string> str_value) {
37   RTC_NOTREACHED();
38   return true;
39 }
40 
ValidateAndGetLength()41 int FieldTrialStructListBase::ValidateAndGetLength() {
42   int length = -1;
43   for (std::unique_ptr<FieldTrialListWrapper>& list : sub_lists_) {
44     if (list->Failed())
45       return -1;
46     else if (!list->Used())
47       continue;
48     else if (length == -1)
49       length = list->Length();
50     else if (length != list->Length())
51       return -1;
52   }
53 
54   return length;
55 }
56 
57 }  // namespace webrtc
58