Refactor SharedMemory::Create and fix a rare file leak.
[chromium-blink-merge.git] / chrome / browser / metrics / chrome_metrics_service_accessor.h
blob8e2dddf0226a6869903dafca70ac85b437f0df10
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 ChromeExtensionDownloaderFactory;
17 class PrefService;
18 class Profile;
20 namespace {
21 class CrashesDOMHandler;
22 class FlashDOMHandler;
25 namespace component_updater {
26 class ComponentUpdateService;
27 void RegisterSwReporterComponent(ComponentUpdateService* cus,
28 PrefService* prefs);
31 namespace extensions {
32 class MetricsPrivateGetIsCrashReportingEnabledFunction;
33 class FileManagerPrivateIsUMAEnabledFunction;
36 namespace prerender {
37 bool IsOmniboxEnabled(Profile* profile);
40 namespace system_logs {
41 class ChromeInternalLogSource;
44 namespace options {
45 class BrowserOptionsHandler;
48 // This class limits and documents access to metrics service helper methods.
49 // Since these methods are private, each user has to be explicitly declared
50 // as a 'friend' below.
51 class ChromeMetricsServiceAccessor : public metrics::MetricsServiceAccessor {
52 private:
53 friend void component_updater::RegisterSwReporterComponent(
54 component_updater::ComponentUpdateService* cus,
55 PrefService* prefs);
56 friend bool prerender::IsOmniboxEnabled(Profile* profile);
57 friend class ChromeExtensionDownloaderFactory;
58 friend class ChromeRenderMessageFilter;
59 friend class ::CrashesDOMHandler;
60 friend class DataReductionProxyChromeSettings;
61 friend class extensions::MetricsPrivateGetIsCrashReportingEnabledFunction;
62 friend class extensions::FileManagerPrivateIsUMAEnabledFunction;
63 friend class ::FlashDOMHandler;
64 friend class system_logs::ChromeInternalLogSource;
65 friend class UmaSessionStats;
66 friend class options::BrowserOptionsHandler;
67 friend void InitiateMetricsReportingChange(
68 bool, const OnMetricsReportingCallbackType&);
69 friend class MetricsServicesManager;
71 FRIEND_TEST_ALL_PREFIXES(ChromeMetricsServiceAccessorTest,
72 MetricsReportingEnabled);
73 FRIEND_TEST_ALL_PREFIXES(ChromeMetricsServiceAccessorTest,
74 CrashReportingEnabled);
76 // Returns true if prefs::kMetricsReportingEnabled is set.
77 // TODO(asvitkine): Consolidate the method in MetricsStateManager.
78 // TODO(asvitkine): This function does not report the correct value on
79 // Android and ChromeOS, see http://crbug.com/362192.
80 static bool IsMetricsReportingEnabled();
82 // Returns true if crash reporting is enabled. This is set at the platform
83 // level for Android and ChromeOS, and otherwise is the same as
84 // IsMetricsReportingEnabled for desktop Chrome.
85 static bool IsCrashReportingEnabled();
87 // Registers a field trial name and group to be used to annotate a UMA report
88 // with a particular Chrome configuration state. A UMA report will be
89 // annotated with this trial group if and only if all events in the report
90 // were created after the trial is registered. Only one group name may be
91 // registered at a time for a given trial name. Only the last group name that
92 // is registered for a given trial name will be recorded. The values passed
93 // in must not correspond to any real field trial in the code.
94 static bool RegisterSyntheticFieldTrial(const std::string& trial_name,
95 const std::string& group_name);
97 // Same as RegisterSyntheticFieldTrial above, but takes a hash for the trial
98 // name, rather than computing it from the string.
99 static bool RegisterSyntheticFieldTrialWithNameHash(
100 uint32_t trial_name_hash,
101 const std::string& group_name);
103 DISALLOW_IMPLICIT_CONSTRUCTORS(ChromeMetricsServiceAccessor);
106 #endif // CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_ACCESSOR_H_