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

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

Issue 1459793002: Android: Allow compiling browser without Java UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 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 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 "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/common/features.h"
9 #include "chrome/common/pref_names.h" 10 #include "chrome/common/pref_names.h"
10 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
11 12
12 #if defined(OS_CHROMEOS) 13 #if defined(OS_CHROMEOS)
13 #include "chrome/browser/chromeos/settings/cros_settings.h" 14 #include "chrome/browser/chromeos/settings/cros_settings.h"
14 #endif 15 #endif
15 16
16 // static 17 // static
17 bool ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled() { 18 bool ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled() {
18 // TODO(blundell): Fix the unittests that don't set up the UI thread and 19 // TODO(blundell): Fix the unittests that don't set up the UI thread and
19 // change this to just be DCHECK_CURRENTLY_ON(). 20 // change this to just be DCHECK_CURRENTLY_ON().
20 DCHECK( 21 DCHECK(
21 !content::BrowserThread::IsMessageLoopValid(content::BrowserThread::UI) || 22 !content::BrowserThread::IsMessageLoopValid(content::BrowserThread::UI) ||
22 content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 23 content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
23 24
24 // This is only possible during unit tests. If the unit test didn't set the 25 // This is only possible during unit tests. If the unit test didn't set the
25 // local_state then it doesn't care about pref value and therefore we return 26 // local_state then it doesn't care about pref value and therefore we return
26 // false. 27 // false.
27 if (!g_browser_process->local_state()) { 28 if (!g_browser_process->local_state()) {
28 DLOG(WARNING) << "Local state has not been set and pref cannot be read"; 29 DLOG(WARNING) << "Local state has not been set and pref cannot be read";
29 return false; 30 return false;
30 } 31 }
31 32
32 #if !defined(OS_ANDROID) 33 #if !BUILDFLAG(ANDROID_JAVA_UI)
33 return IsMetricsReportingEnabled(g_browser_process->local_state()); 34 return IsMetricsReportingEnabled(g_browser_process->local_state());
34 #else 35 #else
35 // Android currently obtain the value for whether the user has 36 // Android currently obtain the value for whether the user has
36 // obtain metrics reporting in non-standard ways. 37 // obtain metrics reporting in non-standard ways.
37 // TODO(gayane): Consolidate metric prefs on all platforms and eliminate this 38 // TODO(gayane): Consolidate metric prefs on all platforms and eliminate this
38 // special-case code, instead having all platforms go through the above flow. 39 // special-case code, instead having all platforms go through the above flow.
39 // http://crbug.com/362192, http://crbug.com/532084 40 // http://crbug.com/362192, http://crbug.com/532084
40 bool pref_value = false; 41 bool pref_value = false;
41 42
42 pref_value = g_browser_process->local_state()->GetBoolean( 43 pref_value = g_browser_process->local_state()->GetBoolean(
43 prefs::kCrashReportingEnabled); 44 prefs::kCrashReportingEnabled);
44 return IsMetricsReportingEnabledWithPrefValue(pref_value); 45 return IsMetricsReportingEnabledWithPrefValue(pref_value);
45 #endif // !defined(OS_ANDROID) 46 #endif // !BUILDFLAG(ANDROID_JAVA_UI)
46 } 47 }
47 48
48 // static 49 // static
49 bool ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial( 50 bool ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial(
50 const std::string& trial_name, 51 const std::string& trial_name,
51 const std::string& group_name) { 52 const std::string& group_name) {
52 return metrics::MetricsServiceAccessor::RegisterSyntheticFieldTrial( 53 return metrics::MetricsServiceAccessor::RegisterSyntheticFieldTrial(
53 g_browser_process->metrics_service(), trial_name, group_name); 54 g_browser_process->metrics_service(), trial_name, group_name);
54 } 55 }
55 56
56 // static 57 // static
57 bool ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrialWithNameHash( 58 bool ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrialWithNameHash(
58 uint32_t trial_name_hash, 59 uint32_t trial_name_hash,
59 const std::string& group_name) { 60 const std::string& group_name) {
60 return metrics::MetricsServiceAccessor:: 61 return metrics::MetricsServiceAccessor::
61 RegisterSyntheticFieldTrialWithNameHash( 62 RegisterSyntheticFieldTrialWithNameHash(
62 g_browser_process->metrics_service(), trial_name_hash, group_name); 63 g_browser_process->metrics_service(), trial_name_hash, group_name);
63 } 64 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698