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

Side by Side Diff: components/metrics/metrics_service_accessor.cc

Issue 2351873002: Clean up UMA 3g experiment and unify metrics enabled pref for Android (Closed)
Patch Set: remove optimization param Created 4 years, 3 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/metrics/metrics_service_accessor.h" 5 #include "components/metrics/metrics_service_accessor.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "components/metrics/metrics_pref_names.h" 9 #include "components/metrics/metrics_pref_names.h"
10 #include "components/metrics/metrics_service.h" 10 #include "components/metrics/metrics_service.h"
11 #include "components/prefs/pref_service.h" 11 #include "components/prefs/pref_service.h"
12 #include "components/variations/metrics_util.h" 12 #include "components/variations/metrics_util.h"
13 13
14 namespace metrics { 14 namespace metrics {
15 15
16 // static 16 // static
17 bool MetricsServiceAccessor::IsMetricsReportingEnabled( 17 bool MetricsServiceAccessor::IsMetricsReportingEnabled(
18 PrefService* pref_service) { 18 PrefService* pref_service) {
19 return IsMetricsReportingEnabledWithPrefValue(
20 pref_service->GetBoolean(prefs::kMetricsReportingEnabled));
21 }
22
23 // static
24 bool MetricsServiceAccessor::IsMetricsReportingEnabledWithPrefValue(
25 bool enabled_in_prefs) {
26 #if defined(GOOGLE_CHROME_BUILD) 19 #if defined(GOOGLE_CHROME_BUILD)
27 // In official builds, disable metrics when reporting field trials are 20 // In official builds, disable metrics when reporting field trials are
28 // forced; otherwise, use the value of the user's preference to determine 21 // forced; otherwise, use the value of the user's preference to determine
29 // whether to enable metrics reporting. 22 // whether to enable metrics reporting.
30 return !base::CommandLine::ForCurrentProcess()->HasSwitch( 23 return !base::CommandLine::ForCurrentProcess()->HasSwitch(
31 switches::kForceFieldTrials) && 24 switches::kForceFieldTrials) &&
32 enabled_in_prefs; 25 pref_service->GetBoolean(prefs::kMetricsReportingEnabled);
33 #else 26 #else
34 // In non-official builds, disable metrics reporting completely. 27 // In non-official builds, disable metrics reporting completely.
35 return false; 28 return false;
36 #endif // defined(GOOGLE_CHROME_BUILD) 29 #endif // defined(GOOGLE_CHROME_BUILD)
37 } 30 }
38 31
39 // static 32 // static
40 bool MetricsServiceAccessor::RegisterSyntheticFieldTrial( 33 bool MetricsServiceAccessor::RegisterSyntheticFieldTrial(
41 MetricsService* metrics_service, 34 MetricsService* metrics_service,
42 const std::string& trial_name, 35 const std::string& trial_name,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 uint32_t group_name_hash) { 67 uint32_t group_name_hash) {
75 if (!metrics_service) 68 if (!metrics_service)
76 return false; 69 return false;
77 70
78 variations::SyntheticTrialGroup trial_group(trial_name_hash, group_name_hash); 71 variations::SyntheticTrialGroup trial_group(trial_name_hash, group_name_hash);
79 metrics_service->RegisterSyntheticFieldTrial(trial_group); 72 metrics_service->RegisterSyntheticFieldTrial(trial_group);
80 return true; 73 return true;
81 } 74 }
82 75
83 } // namespace metrics 76 } // namespace metrics
OLDNEW
« no previous file with comments | « components/metrics/metrics_service_accessor.h ('k') | components/metrics/net/cellular_logic_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698