Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / metrics / chrome_metrics_service_accessor.h
blobe99d121c3d3657e38d16dd87e376abbe3cc0a841
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_ACCESSOR_H_
6 #define CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_ACCESSOR_H_
8 #include <stdint.h>
9 #include <string>
11 #include "base/gtest_prod_util.h"
12 #include "base/macros.h"
13 #include "chrome/browser/metrics/metrics_reporting_state.h"
14 #include "components/metrics/metrics_service_accessor.h"
16 class BrowserProcessImpl;
17 class ChromeExtensionDownloaderFactory;
18 class PrefService;
19 class Profile;
21 namespace {
22 class CrashesDOMHandler;
23 class FlashDOMHandler;
26 namespace component_updater {
27 class ComponentUpdateService;
28 void RegisterSwReporterComponent(ComponentUpdateService* cus);
31 namespace domain_reliability {
32 class DomainReliabilityServiceFactory;
35 namespace extensions {
36 class FileManagerPrivateIsUMAEnabledFunction;
37 class MetricsPrivateGetIsCrashReportingEnabledFunction;
40 namespace options {
41 class BrowserOptionsHandler;
44 namespace prerender {
45 bool IsOmniboxEnabled(Profile* profile);
48 namespace safe_browsing {
49 class IncidentReportingService;
52 namespace speech {
53 class ChromeSpeechRecognitionManagerDelegate;
56 namespace system_logs {
57 class ChromeInternalLogSource;
60 // This class limits and documents access to metrics service helper methods.
61 // Since these methods are private, each user has to be explicitly declared
62 // as a 'friend' below.
63 class ChromeMetricsServiceAccessor : public metrics::MetricsServiceAccessor {
64 private:
65 friend class ::CrashesDOMHandler;
66 friend class ::FlashDOMHandler;
67 friend class BrowserProcessImpl;
68 friend class ChromeExtensionDownloaderFactory;
69 friend class ChromeRenderMessageFilter;
70 friend void component_updater::RegisterSwReporterComponent(
71 component_updater::ComponentUpdateService* cus);
72 friend class DataReductionProxyChromeSettings;
73 friend class domain_reliability::DomainReliabilityServiceFactory;
74 friend class extensions::MetricsPrivateGetIsCrashReportingEnabledFunction;
75 friend class extensions::FileManagerPrivateIsUMAEnabledFunction;
76 friend void InitiateMetricsReportingChange(
77 bool, const OnMetricsReportingCallbackType&);
78 friend class MetricsServicesManager;
79 friend class options::BrowserOptionsHandler;
80 friend bool prerender::IsOmniboxEnabled(Profile* profile);
81 friend class safe_browsing::IncidentReportingService;
82 friend class speech::ChromeSpeechRecognitionManagerDelegate;
83 friend class StackSamplingConfiguration;
84 friend class system_logs::ChromeInternalLogSource;
85 friend class UmaSessionStats;
87 FRIEND_TEST_ALL_PREFIXES(ChromeMetricsServiceAccessorTest,
88 MetricsReportingEnabled);
90 // Returns true if metrics reporting is enabled.
91 // TODO(gayane): Consoldiate metric prefs on all platforms
92 // http://crbug.com/362192, http://crbug.com/532084
93 static bool IsMetricsAndCrashReportingEnabled();
95 // Registers a field trial name and group to be used to annotate a UMA report
96 // with a particular Chrome configuration state. A UMA report will be
97 // annotated with this trial group if and only if all events in the report
98 // were created after the trial is registered. Only one group name may be
99 // registered at a time for a given trial name. Only the last group name that
100 // is registered for a given trial name will be recorded. The values passed
101 // in must not correspond to any real field trial in the code.
102 static bool RegisterSyntheticFieldTrial(const std::string& trial_name,
103 const std::string& group_name);
105 // Same as RegisterSyntheticFieldTrial above, but takes a hash for the trial
106 // name, rather than computing it from the string.
107 static bool RegisterSyntheticFieldTrialWithNameHash(
108 uint32_t trial_name_hash,
109 const std::string& group_name);
111 DISALLOW_IMPLICIT_CONSTRUCTORS(ChromeMetricsServiceAccessor);
114 #endif // CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_ACCESSOR_H_