Add ENABLE_MEDIA_ROUTER define to builds other than Android and iOS.
[chromium-blink-merge.git] / chrome / browser / metrics / metrics_services_manager.h
blob7a05c80be4b83c22a312fdfbcab5d7925db910d0
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_METRICS_SERVICES_MANAGER_H_
6 #define CHROME_BROWSER_METRICS_METRICS_SERVICES_MANAGER_H_
8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/prefs/pref_change_registrar.h"
11 #include "base/threading/thread_checker.h"
13 class ChromeMetricsServiceClient;
14 class PrefService;
16 namespace base {
17 class FilePath;
20 namespace metrics {
21 class MetricsService;
22 class MetricsStateManager;
25 namespace rappor {
26 class RapporService;
29 namespace chrome_variations {
30 class VariationsService;
33 // MetricsServicesManager is a helper class that has ownership over the various
34 // metrics-related services in Chrome: MetricsService (via its client),
35 // RapporService and VariationsService.
36 class MetricsServicesManager {
37 public:
38 // Creates the MetricsServicesManager with the |local_state| prefs service.
39 explicit MetricsServicesManager(PrefService* local_state);
40 virtual ~MetricsServicesManager();
42 // Returns the MetricsService, creating it if it hasn't been created yet (and
43 // additionally creating the ChromeMetricsServiceClient in that case).
44 metrics::MetricsService* GetMetricsService();
46 // Returns the GetRapporService, creating it if it hasn't been created yet.
47 rappor::RapporService* GetRapporService();
49 // Returns the VariationsService, creating it if it hasn't been created yet.
50 chrome_variations::VariationsService* GetVariationsService();
52 // Should be called when a plugin loading error occurs.
53 void OnPluginLoadingError(const base::FilePath& plugin_path);
55 // Update the managed services when permissions for recording/uploading
56 // metrics change.
57 void UpdatePermissions(bool may_record, bool may_upload);
59 // Update the managed services when permissions for uploading metrics change.
60 void UpdateUploadPermissions(bool may_upload);
62 private:
63 // Update the managed services when permissions for recording/uploading
64 // metrics change.
65 void UpdateRapporService();
67 // Returns the ChromeMetricsServiceClient, creating it if it hasn't been
68 // created yet (and additionally creating the MetricsService in that case).
69 ChromeMetricsServiceClient* GetChromeMetricsServiceClient();
71 metrics::MetricsStateManager* GetMetricsStateManager();
73 // Ensures that all functions are called from the same thread.
74 base::ThreadChecker thread_checker_;
76 // Weak pointer to the local state prefs store.
77 PrefService* local_state_;
79 // A change registrar for local_state_;
80 PrefChangeRegistrar pref_change_registrar_;
82 // The current metrics reporting setting.
83 bool may_upload_;
85 // The current metrics recording setting.
86 bool may_record_;
88 // MetricsStateManager which is passed as a parameter to service constructors.
89 scoped_ptr<metrics::MetricsStateManager> metrics_state_manager_;
91 // Chrome embedder implementation of the MetricsServiceClient. Owns the
92 // MetricsService.
93 scoped_ptr<ChromeMetricsServiceClient> metrics_service_client_;
95 // The RapporService, for RAPPOR metric uploads.
96 scoped_ptr<rappor::RapporService> rappor_service_;
98 // The VariationsService, for server-side experiments infrastructure.
99 scoped_ptr<chrome_variations::VariationsService> variations_service_;
101 DISALLOW_COPY_AND_ASSIGN(MetricsServicesManager);
104 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICES_MANAGER_H_