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