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 "chrome/browser/metrics/chrome_metrics_service_accessor.h" | 5 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/common/features.h" | 9 #include "chrome/common/features.h" |
10 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 42 content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
43 | 43 |
44 // This is only possible during unit tests. If the unit test didn't set the | 44 // This is only possible during unit tests. If the unit test didn't set the |
45 // local_state then it doesn't care about pref value and therefore we return | 45 // local_state then it doesn't care about pref value and therefore we return |
46 // false. | 46 // false. |
47 if (!g_browser_process->local_state()) { | 47 if (!g_browser_process->local_state()) { |
48 DLOG(WARNING) << "Local state has not been set and pref cannot be read"; | 48 DLOG(WARNING) << "Local state has not been set and pref cannot be read"; |
49 return false; | 49 return false; |
50 } | 50 } |
51 | 51 |
52 #if !BUILDFLAG(ANDROID_JAVA_UI) | |
53 return IsMetricsReportingEnabled(g_browser_process->local_state()); | 52 return IsMetricsReportingEnabled(g_browser_process->local_state()); |
54 #else | |
55 // Android currently obtain the value for whether the user has | |
56 // obtain metrics reporting in non-standard ways. | |
57 // TODO(gayane): Consolidate metric prefs on all platforms and eliminate this | |
58 // special-case code, instead having all platforms go through the above flow. | |
59 // http://crbug.com/362192, http://crbug.com/532084 | |
60 bool pref_value = false; | |
61 | |
62 pref_value = g_browser_process->local_state()->GetBoolean( | |
63 prefs::kCrashReportingEnabled); | |
64 return IsMetricsReportingEnabledWithPrefValue(pref_value); | |
65 #endif // !BUILDFLAG(ANDROID_JAVA_UI) | |
66 } | 53 } |
67 | 54 |
68 // static | 55 // static |
69 bool ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial( | 56 bool ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial( |
70 const std::string& trial_name, | 57 const std::string& trial_name, |
71 const std::string& group_name) { | 58 const std::string& group_name) { |
72 return metrics::MetricsServiceAccessor::RegisterSyntheticFieldTrial( | 59 return metrics::MetricsServiceAccessor::RegisterSyntheticFieldTrial( |
73 g_browser_process->metrics_service(), trial_name, group_name); | 60 g_browser_process->metrics_service(), trial_name, group_name); |
74 } | 61 } |
75 | 62 |
76 // static | 63 // static |
77 bool ChromeMetricsServiceAccessor::RegisterSyntheticMultiGroupFieldTrial( | 64 bool ChromeMetricsServiceAccessor::RegisterSyntheticMultiGroupFieldTrial( |
78 const std::string& trial_name, | 65 const std::string& trial_name, |
79 const std::vector<uint32_t>& group_name_hashes) { | 66 const std::vector<uint32_t>& group_name_hashes) { |
80 return metrics::MetricsServiceAccessor::RegisterSyntheticMultiGroupFieldTrial( | 67 return metrics::MetricsServiceAccessor::RegisterSyntheticMultiGroupFieldTrial( |
81 g_browser_process->metrics_service(), trial_name, group_name_hashes); | 68 g_browser_process->metrics_service(), trial_name, group_name_hashes); |
82 } | 69 } |
83 | 70 |
84 // static | 71 // static |
85 bool ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrialWithNameHash( | 72 bool ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrialWithNameHash( |
86 uint32_t trial_name_hash, | 73 uint32_t trial_name_hash, |
87 const std::string& group_name) { | 74 const std::string& group_name) { |
88 return metrics::MetricsServiceAccessor:: | 75 return metrics::MetricsServiceAccessor:: |
89 RegisterSyntheticFieldTrialWithNameHash( | 76 RegisterSyntheticFieldTrialWithNameHash( |
90 g_browser_process->metrics_service(), trial_name_hash, group_name); | 77 g_browser_process->metrics_service(), trial_name_hash, group_name); |
91 } | 78 } |
OLD | NEW |