Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "net/reporting/reporting_controls.h" | |
| 6 | |
| 7 #include <cstring> | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/command_line.h" | |
| 11 #include "base/metrics/field_trial.h" | |
| 12 #include "net/reporting/reporting_metrics.h" | |
| 13 | |
| 14 namespace net { | |
| 15 | |
| 16 namespace { | |
| 17 | |
| 18 const bool kDefaultEnabled = false; | |
| 19 | |
| 20 const char kFieldTrialName[] = "Reporting-Enable"; | |
| 21 const char kFieldTrialValuePrefix[] = "enable"; | |
| 22 | |
| 23 } // namespace | |
| 24 | |
| 25 bool GetReportingEnabled(const char* disable_switch_name, | |
| 26 const char* enable_switch_name) { | |
| 27 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | |
| 28 if (disable_switch_name && command_line->HasSwitch(disable_switch_name)) { | |
| 29 HistogramEnabledState(ENABLED_STATE_DISABLED_COMMAND_LINE); | |
| 30 return false; | |
| 31 } | |
| 32 if (enable_switch_name && command_line->HasSwitch(enable_switch_name)) { | |
| 33 HistogramEnabledState(ENABLED_STATE_ENABLED_COMMAND_LINE); | |
| 34 return true; | |
| 35 } | |
| 36 | |
| 37 if (base::FieldTrialList::TrialExists(kFieldTrialName)) { | |
| 38 std::string value = base::FieldTrialList::FindFullName(kFieldTrialName); | |
| 39 bool enabled = !value.compare(0, strlen(kFieldTrialValuePrefix), | |
| 40 kFieldTrialValuePrefix); | |
| 41 if (enabled) | |
| 42 HistogramEnabledState(ENABLED_STATE_ENABLED_FIELD_TRIAL); | |
| 43 else | |
| 44 HistogramEnabledState(ENABLED_STATE_DISABLED_FIELD_TRIAL); | |
| 45 return enabled; | |
| 46 } | |
| 47 | |
| 48 if (kDefaultEnabled) | |
| 49 HistogramEnabledState(ENABLED_STATE_ENABLED_DEFAULT); | |
| 50 else | |
| 51 HistogramEnabledState(ENABLED_STATE_DISABLED_DEFAULT); | |
| 52 return kDefaultEnabled; | |
|
Ryan Sleevi
2017/01/03 21:28:12
As mentioned in the header, this all seems like so
Julia Tuttle
2017/01/25 20:27:45
Obsolete; I'm now using base::Feature.
| |
| 53 } | |
| 54 | |
| 55 } // namespace net | |
| OLD | NEW |