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

Side by Side Diff: chrome/browser/metrics/chrome_metrics_service_accessor.cc

Issue 916133003: Fix ChromeMetricsServiceAccessor::IsMetricsReportingEnabled on CrOs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « no previous file | chrome/browser/metrics/chrome_metrics_service_accessor_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/metrics/chrome_metrics_service_accessor.h" 5 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h"
6 6
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/metrics/metrics_services_manager.h"
9 #include "chrome/common/pref_names.h" 10 #include "chrome/common/pref_names.h"
10 #include "components/metrics/metrics_service.h" 11 #include "components/metrics/metrics_service.h"
11 #include "components/variations/metrics_util.h" 12 #include "components/variations/metrics_util.h"
12 13
13 #if defined(OS_CHROMEOS) 14 #if defined(OS_CHROMEOS)
14 #include "chrome/browser/chromeos/settings/cros_settings.h" 15 #include "chrome/browser/chromeos/settings/cros_settings.h"
15 #endif 16 #endif
16 17
17 // static 18 // static
18 bool ChromeMetricsServiceAccessor::IsMetricsReportingEnabled() { 19 bool ChromeMetricsServiceAccessor::IsMetricsReportingEnabled() {
19 bool result = false; 20 return g_browser_process->GetMetricsServicesManager()->
20 const PrefService* local_state = g_browser_process->local_state(); 21 IsMetricsReportingEnabled();
Alexei Svitkine (slow) 2015/02/11 21:58:26 IsMetricsReportingEnabled() on MetricsServicesMana
Alexei Svitkine (slow) 2015/02/11 22:06:11 I just took a glance, and only place that relies o
anthonyvd 2015/02/12 15:48:54 Done.
anthonyvd 2015/02/12 15:48:55 Done.
21 if (local_state) {
22 const PrefService::Preference* uma_pref =
23 local_state->FindPreference(prefs::kMetricsReportingEnabled);
24 if (uma_pref) {
25 bool success = uma_pref->GetValue()->GetAsBoolean(&result);
26 DCHECK(success);
27 }
28 }
29 return result;
30 } 22 }
31 23
32 bool ChromeMetricsServiceAccessor::IsCrashReportingEnabled() { 24 bool ChromeMetricsServiceAccessor::IsCrashReportingEnabled() {
33 #if defined(GOOGLE_CHROME_BUILD) 25 #if defined(GOOGLE_CHROME_BUILD)
34 #if defined(OS_CHROMEOS) 26 #if defined(OS_ANDROID)
35 bool reporting_enabled = false;
36 chromeos::CrosSettings::Get()->GetBoolean(chromeos::kStatsReportingPref,
37 &reporting_enabled);
Alexei Svitkine (slow) 2015/02/11 21:58:26 Why did you remove this?
anthonyvd 2015/02/12 15:48:55 It was a fix for ChromeMetricsServiceAccessor::IsM
38 return reporting_enabled;
39 #elif defined(OS_ANDROID)
40 // Android has its own settings for metrics / crash uploading. 27 // Android has its own settings for metrics / crash uploading.
41 const PrefService* prefs = g_browser_process->local_state(); 28 const PrefService* prefs = g_browser_process->local_state();
42 return prefs->GetBoolean(prefs::kCrashReportingEnabled); 29 return prefs->GetBoolean(prefs::kCrashReportingEnabled);
43 #else 30 #else
44 return ChromeMetricsServiceAccessor::IsMetricsReportingEnabled(); 31 return ChromeMetricsServiceAccessor::IsMetricsReportingEnabled();
45 #endif 32 #endif
46 #else 33 #else
47 return false; 34 return false;
48 #endif 35 #endif
49 } 36 }
50 37
51 // static 38 // static
52 bool ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial( 39 bool ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial(
53 const std::string& trial_name, 40 const std::string& trial_name,
54 const std::string& group_name) { 41 const std::string& group_name) {
55 return RegisterSyntheticFieldTrialWithNameHash(metrics::HashName(trial_name), 42 return RegisterSyntheticFieldTrialWithNameHash(metrics::HashName(trial_name),
56 group_name); 43 group_name);
57 } 44 }
58 45
59 // static 46 // static
60 bool ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrialWithNameHash( 47 bool ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrialWithNameHash(
61 uint32_t trial_name_hash, 48 uint32_t trial_name_hash,
62 const std::string& group_name) { 49 const std::string& group_name) {
63 return metrics::MetricsServiceAccessor::RegisterSyntheticFieldTrial( 50 return metrics::MetricsServiceAccessor::RegisterSyntheticFieldTrial(
64 g_browser_process->metrics_service(), 51 g_browser_process->metrics_service(),
65 trial_name_hash, 52 trial_name_hash,
66 metrics::HashName(group_name)); 53 metrics::HashName(group_name));
67 } 54 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/metrics/chrome_metrics_service_accessor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698