Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(543)

Unified Diff: net/reporting/reporting_controls.cc

Issue 2249213002: [OBSOLETE] Reporting: Initial implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/reporting/reporting_controls.cc
diff --git a/net/reporting/reporting_controls.cc b/net/reporting/reporting_controls.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5fe9d710b74c8587d419818e6e2b66b6437c863d
--- /dev/null
+++ b/net/reporting/reporting_controls.cc
@@ -0,0 +1,55 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/reporting/reporting_controls.h"
+
+#include <cstring>
+#include <string>
+
+#include "base/command_line.h"
+#include "base/metrics/field_trial.h"
+#include "net/reporting/reporting_metrics.h"
+
+namespace net {
+
+namespace {
+
+const bool kDefaultEnabled = false;
+
+const char kFieldTrialName[] = "Reporting-Enable";
+const char kFieldTrialValuePrefix[] = "enable";
+
+} // namespace
+
+bool GetReportingEnabled(const char* disable_switch_name,
+ const char* enable_switch_name) {
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+ if (disable_switch_name && command_line->HasSwitch(disable_switch_name)) {
+ HistogramEnabledState(ENABLED_STATE_DISABLED_COMMAND_LINE);
+ return false;
+ }
+ if (enable_switch_name && command_line->HasSwitch(enable_switch_name)) {
+ HistogramEnabledState(ENABLED_STATE_ENABLED_COMMAND_LINE);
+ return true;
+ }
+
+ if (base::FieldTrialList::TrialExists(kFieldTrialName)) {
+ std::string value = base::FieldTrialList::FindFullName(kFieldTrialName);
+ bool enabled = !value.compare(0, strlen(kFieldTrialValuePrefix),
+ kFieldTrialValuePrefix);
+ if (enabled)
+ HistogramEnabledState(ENABLED_STATE_ENABLED_FIELD_TRIAL);
+ else
+ HistogramEnabledState(ENABLED_STATE_DISABLED_FIELD_TRIAL);
+ return enabled;
+ }
+
+ if (kDefaultEnabled)
+ HistogramEnabledState(ENABLED_STATE_ENABLED_DEFAULT);
+ else
+ HistogramEnabledState(ENABLED_STATE_DISABLED_DEFAULT);
+ 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.
+}
+
+} // namespace net

Powered by Google App Engine
This is Rietveld 408576698