| 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 COMPONENTS_METRICS_SERVICES_MANAGER_METRICS_SERVICES_MANAGER_H_ | 5 #ifndef COMPONENTS_METRICS_SERVICES_MANAGER_METRICS_SERVICES_MANAGER_H_ |
| 6 #define COMPONENTS_METRICS_SERVICES_MANAGER_METRICS_SERVICES_MANAGER_H_ | 6 #define COMPONENTS_METRICS_SERVICES_MANAGER_METRICS_SERVICES_MANAGER_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 9 |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "base/threading/thread_checker.h" | 11 #include "base/threading/thread_checker.h" |
| 11 | 12 |
| 12 namespace base { | 13 namespace base { |
| 13 class FilePath; | 14 class FilePath; |
| 14 } | 15 } |
| 15 | 16 |
| 16 namespace metrics { | 17 namespace metrics { |
| 17 class MetricsService; | 18 class MetricsService; |
| 18 class MetricsServiceClient; | 19 class MetricsServiceClient; |
| 19 class MetricsStateManager; | 20 class MetricsStateManager; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 31 | 32 |
| 32 class MetricsServicesManagerClient; | 33 class MetricsServicesManagerClient; |
| 33 | 34 |
| 34 // MetricsServicesManager is a helper class for embedders that use the various | 35 // MetricsServicesManager is a helper class for embedders that use the various |
| 35 // metrics-related services in a Chrome-like fashion: MetricsService (via its | 36 // metrics-related services in a Chrome-like fashion: MetricsService (via its |
| 36 // client), RapporService and VariationsService. | 37 // client), RapporService and VariationsService. |
| 37 class MetricsServicesManager { | 38 class MetricsServicesManager { |
| 38 public: | 39 public: |
| 39 // Creates the MetricsServicesManager with the given client. | 40 // Creates the MetricsServicesManager with the given client. |
| 40 explicit MetricsServicesManager( | 41 explicit MetricsServicesManager( |
| 41 scoped_ptr<MetricsServicesManagerClient> client); | 42 std::unique_ptr<MetricsServicesManagerClient> client); |
| 42 virtual ~MetricsServicesManager(); | 43 virtual ~MetricsServicesManager(); |
| 43 | 44 |
| 44 // Returns the MetricsService, creating it if it hasn't been created yet (and | 45 // Returns the MetricsService, creating it if it hasn't been created yet (and |
| 45 // additionally creating the MetricsServiceClient in that case). | 46 // additionally creating the MetricsServiceClient in that case). |
| 46 metrics::MetricsService* GetMetricsService(); | 47 metrics::MetricsService* GetMetricsService(); |
| 47 | 48 |
| 48 // Returns the RapporService, creating it if it hasn't been created yet. | 49 // Returns the RapporService, creating it if it hasn't been created yet. |
| 49 rappor::RapporService* GetRapporService(); | 50 rappor::RapporService* GetRapporService(); |
| 50 | 51 |
| 51 // Returns the VariationsService, creating it if it hasn't been created yet. | 52 // Returns the VariationsService, creating it if it hasn't been created yet. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 73 // Returns the MetricsServiceClient, creating it if it hasn't been | 74 // Returns the MetricsServiceClient, creating it if it hasn't been |
| 74 // created yet (and additionally creating the MetricsService in that case). | 75 // created yet (and additionally creating the MetricsService in that case). |
| 75 metrics::MetricsServiceClient* GetMetricsServiceClient(); | 76 metrics::MetricsServiceClient* GetMetricsServiceClient(); |
| 76 | 77 |
| 77 metrics::MetricsStateManager* GetMetricsStateManager(); | 78 metrics::MetricsStateManager* GetMetricsStateManager(); |
| 78 | 79 |
| 79 // Update which services are running to match current permissions. | 80 // Update which services are running to match current permissions. |
| 80 void UpdateRunningServices(); | 81 void UpdateRunningServices(); |
| 81 | 82 |
| 82 // The client passed in from the embedder. | 83 // The client passed in from the embedder. |
| 83 scoped_ptr<MetricsServicesManagerClient> client_; | 84 std::unique_ptr<MetricsServicesManagerClient> client_; |
| 84 | 85 |
| 85 // Ensures that all functions are called from the same thread. | 86 // Ensures that all functions are called from the same thread. |
| 86 base::ThreadChecker thread_checker_; | 87 base::ThreadChecker thread_checker_; |
| 87 | 88 |
| 88 // The current metrics reporting setting. | 89 // The current metrics reporting setting. |
| 89 bool may_upload_; | 90 bool may_upload_; |
| 90 | 91 |
| 91 // The current metrics recording setting. | 92 // The current metrics recording setting. |
| 92 bool may_record_; | 93 bool may_record_; |
| 93 | 94 |
| 94 // The MetricsServiceClient. Owns the MetricsService. | 95 // The MetricsServiceClient. Owns the MetricsService. |
| 95 scoped_ptr<metrics::MetricsServiceClient> metrics_service_client_; | 96 std::unique_ptr<metrics::MetricsServiceClient> metrics_service_client_; |
| 96 | 97 |
| 97 // The RapporService, for RAPPOR metric uploads. | 98 // The RapporService, for RAPPOR metric uploads. |
| 98 scoped_ptr<rappor::RapporService> rappor_service_; | 99 std::unique_ptr<rappor::RapporService> rappor_service_; |
| 99 | 100 |
| 100 // The VariationsService, for server-side experiments infrastructure. | 101 // The VariationsService, for server-side experiments infrastructure. |
| 101 scoped_ptr<variations::VariationsService> variations_service_; | 102 std::unique_ptr<variations::VariationsService> variations_service_; |
| 102 | 103 |
| 103 DISALLOW_COPY_AND_ASSIGN(MetricsServicesManager); | 104 DISALLOW_COPY_AND_ASSIGN(MetricsServicesManager); |
| 104 }; | 105 }; |
| 105 | 106 |
| 106 } // namespace metrics_services_manager | 107 } // namespace metrics_services_manager |
| 107 | 108 |
| 108 #endif // COMPONENTS_METRICS_SERVICES_MANAGER_METRICS_SERVICES_MANAGER_H_ | 109 #endif // COMPONENTS_METRICS_SERVICES_MANAGER_METRICS_SERVICES_MANAGER_H_ |
| OLD | NEW |