[email protected] | c3cac95 | 2014-05-09 01:51:18 | [diff] [blame] | 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. |
| 4 | |
| 5 | #ifndef CHROME_BROWSER_METRICS_METRICS_SERVICES_MANAGER_H_ |
| 6 | #define CHROME_BROWSER_METRICS_METRICS_SERVICES_MANAGER_H_ |
| 7 | |
| 8 | #include "base/basictypes.h" |
| 9 | #include "base/memory/scoped_ptr.h" |
| 10 | #include "base/threading/thread_checker.h" |
| 11 | |
[email protected] | 037642f | 2014-05-29 20:40:50 | [diff] [blame] | 12 | class ChromeMetricsServiceClient; |
[email protected] | c3cac95 | 2014-05-09 01:51:18 | [diff] [blame] | 13 | class MetricsService; |
| 14 | class PrefService; |
| 15 | |
[email protected] | 544246e | 2014-06-06 11:22:28 | [diff] [blame] | 16 | namespace base { |
| 17 | class FilePath; |
| 18 | } |
| 19 | |
[email protected] | c3cac95 | 2014-05-09 01:51:18 | [diff] [blame] | 20 | namespace metrics { |
| 21 | class MetricsStateManager; |
| 22 | } |
| 23 | |
| 24 | namespace rappor { |
| 25 | class RapporService; |
| 26 | } |
| 27 | |
| 28 | namespace chrome_variations { |
| 29 | class VariationsService; |
| 30 | } |
| 31 | |
| 32 | // MetricsServicesManager is a helper class that has ownership over the various |
[email protected] | 037642f | 2014-05-29 20:40:50 | [diff] [blame] | 33 | // metrics-related services in Chrome: MetricsService (via its client), |
| 34 | // RapporService and VariationsService. |
[email protected] | c3cac95 | 2014-05-09 01:51:18 | [diff] [blame] | 35 | class MetricsServicesManager { |
| 36 | public: |
| 37 | // Creates the MetricsServicesManager with the |local_state| prefs service. |
| 38 | explicit MetricsServicesManager(PrefService* local_state); |
| 39 | virtual ~MetricsServicesManager(); |
| 40 | |
[email protected] | 4a55a71 | 2014-06-08 16:50:34 | [diff] [blame^] | 41 | // Returns the MetricsService, creating it if it hasn't been created yet (and |
| 42 | // additionally creating the ChromeMetricsServiceClient in that case). |
[email protected] | c3cac95 | 2014-05-09 01:51:18 | [diff] [blame] | 43 | MetricsService* GetMetricsService(); |
| 44 | |
| 45 | // Returns the GetRapporService, creating it if it hasn't been created yet. |
| 46 | rappor::RapporService* GetRapporService(); |
| 47 | |
| 48 | // Returns the VariationsService, creating it if it hasn't been created yet. |
| 49 | chrome_variations::VariationsService* GetVariationsService(); |
| 50 | |
[email protected] | 544246e | 2014-06-06 11:22:28 | [diff] [blame] | 51 | // Should be called when a plugin loading error occurs. |
| 52 | void OnPluginLoadingError(const base::FilePath& plugin_path); |
| 53 | |
[email protected] | c3cac95 | 2014-05-09 01:51:18 | [diff] [blame] | 54 | private: |
[email protected] | 4a55a71 | 2014-06-08 16:50:34 | [diff] [blame^] | 55 | // Returns the ChromeMetricsServiceClient, creating it if it hasn't been |
| 56 | // created yet (and additionally creating the MetricsService in that case). |
| 57 | ChromeMetricsServiceClient* GetChromeMetricsServiceClient(); |
| 58 | |
[email protected] | c3cac95 | 2014-05-09 01:51:18 | [diff] [blame] | 59 | metrics::MetricsStateManager* GetMetricsStateManager(); |
| 60 | |
[email protected] | 3c70256f | 2014-05-22 03:02:12 | [diff] [blame] | 61 | // Returns true iff metrics reporting is enabled. |
| 62 | bool IsMetricsReportingEnabled() const; |
| 63 | |
[email protected] | c3cac95 | 2014-05-09 01:51:18 | [diff] [blame] | 64 | // Ensures that all functions are called from the same thread. |
| 65 | base::ThreadChecker thread_checker_; |
| 66 | |
| 67 | // Weak pointer to the local state prefs store. |
| 68 | PrefService* local_state_; |
| 69 | |
| 70 | // MetricsStateManager which is passed as a parameter to service constructors. |
| 71 | scoped_ptr<metrics::MetricsStateManager> metrics_state_manager_; |
| 72 | |
[email protected] | 037642f | 2014-05-29 20:40:50 | [diff] [blame] | 73 | // Chrome embedder implementation of the MetricsServiceClient. Owns the |
| 74 | // MetricsService. |
| 75 | scoped_ptr<ChromeMetricsServiceClient> metrics_service_client_; |
[email protected] | c3cac95 | 2014-05-09 01:51:18 | [diff] [blame] | 76 | |
| 77 | // The RapporService, for RAPPOR metric uploads. |
| 78 | scoped_ptr<rappor::RapporService> rappor_service_; |
| 79 | |
| 80 | // The VariationsService, for server-side experiments infrastructure. |
| 81 | scoped_ptr<chrome_variations::VariationsService> variations_service_; |
| 82 | |
| 83 | DISALLOW_COPY_AND_ASSIGN(MetricsServicesManager); |
| 84 | }; |
| 85 | |
| 86 | #endif // CHROME_BROWSER_METRICS_METRICS_SERVICES_MANAGER_H_ |