| OLD | NEW |
| 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 "base/metrics/histogram_macros.h" |
| 9 #include "components/metrics/metrics_pref_names.h" | 10 #include "components/metrics/metrics_pref_names.h" |
| 10 #include "components/metrics/metrics_service.h" | 11 #include "components/metrics/metrics_service.h" |
| 11 #include "components/prefs/pref_service.h" | 12 #include "components/prefs/pref_service.h" |
| 12 #include "components/variations/metrics_util.h" | 13 #include "components/variations/metrics_util.h" |
| 13 | 14 |
| 14 namespace metrics { | 15 namespace metrics { |
| 15 | 16 |
| 16 // static | 17 // static |
| 17 bool MetricsServiceAccessor::IsMetricsReportingEnabled( | 18 bool MetricsServiceAccessor::IsMetricsReportingEnabled( |
| 18 PrefService* pref_service) { | 19 PrefService* pref_service) { |
| 19 #if defined(GOOGLE_CHROME_BUILD) | 20 #if defined(GOOGLE_CHROME_BUILD) |
| 21 UMA_HISTOGRAM_BOOLEAN("UMA.Dbg.IsMetricsReportingEnabled.ChromeBuild
", true); |
| 22 UMA_HISTOGRAM_BOOLEAN("UMA.Dbg.IsMetricsReportingEnabled.PrefValue",
pref_service->GetBoolean(prefs::kMetricsReportingEnabled)); |
| 23 UMA_HISTOGRAM_BOOLEAN("UMA.Dbg.IsMetricsReportingEnabled.PrefIsManag
ed", pref_service->IsManagedPreference(prefs::kMetricsReportingEnabled)); |
| 24 UMA_HISTOGRAM_BOOLEAN("UMA.Dbg.IsMetricsReportingEnabled.PrefIsManag
edByCust", pref_service->IsPreferenceManagedByCustodian(prefs::kMetricsReporting
Enabled)); |
| 25 UMA_HISTOGRAM_BOOLEAN("UMA.Dbg.IsMetricsReportingEnabled.PrefIsModif
iable", pref_service->IsPreferenceManagedByCustodian(prefs::kMetricsReportingEna
bled)); |
| 26 UMA_HISTOGRAM_BOOLEAN("UMA.Dbg.IsMetricsReportingEnabled.PrefIsSet",
pref_service->HasPrefPath(prefs::kMetricsReportingEnabled)); |
| 27 |
| 20 // In official builds, disable metrics when reporting field trials are | 28 // In official builds, disable metrics when reporting field trials are |
| 21 // forced; otherwise, use the value of the user's preference to determine | 29 // forced; otherwise, use the value of the user's preference to determine |
| 22 // whether to enable metrics reporting. | 30 // whether to enable metrics reporting. |
| 23 return !base::CommandLine::ForCurrentProcess()->HasSwitch( | 31 return !base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 24 switches::kForceFieldTrials) && | 32 switches::kForceFieldTrials) && |
| 25 pref_service->GetBoolean(prefs::kMetricsReportingEnabled); | 33 pref_service->GetBoolean(prefs::kMetricsReportingEnabled); |
| 26 #else | 34 #else |
| 35 UMA_HISTOGRAM_BOOLEAN("UMA.Dbg.IsMetricsReportingEnabled.ChromeBuild", false); |
| 36 |
| 27 // In non-official builds, disable metrics reporting completely. | 37 // In non-official builds, disable metrics reporting completely. |
| 28 return false; | 38 return false; |
| 29 #endif // defined(GOOGLE_CHROME_BUILD) | 39 #endif // defined(GOOGLE_CHROME_BUILD) |
| 30 } | 40 } |
| 31 | 41 |
| 32 // static | 42 // static |
| 33 bool MetricsServiceAccessor::RegisterSyntheticFieldTrial( | 43 bool MetricsServiceAccessor::RegisterSyntheticFieldTrial( |
| 34 MetricsService* metrics_service, | 44 MetricsService* metrics_service, |
| 35 base::StringPiece trial_name, | 45 base::StringPiece trial_name, |
| 36 base::StringPiece group_name) { | 46 base::StringPiece group_name) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 67 uint32_t group_name_hash) { | 77 uint32_t group_name_hash) { |
| 68 if (!metrics_service) | 78 if (!metrics_service) |
| 69 return false; | 79 return false; |
| 70 | 80 |
| 71 variations::SyntheticTrialGroup trial_group(trial_name_hash, group_name_hash); | 81 variations::SyntheticTrialGroup trial_group(trial_name_hash, group_name_hash); |
| 72 metrics_service->RegisterSyntheticFieldTrial(trial_group); | 82 metrics_service->RegisterSyntheticFieldTrial(trial_group); |
| 73 return true; | 83 return true; |
| 74 } | 84 } |
| 75 | 85 |
| 76 } // namespace metrics | 86 } // namespace metrics |
| OLD | NEW |