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 CHROMECAST_BROWSER_METRICS_CAST_METRICS_SERVICE_CLIENT_H_ | 5 #ifndef CHROMECAST_BROWSER_METRICS_CAST_METRICS_SERVICE_CLIENT_H_ |
6 #define CHROMECAST_BROWSER_METRICS_CAST_METRICS_SERVICE_CLIENT_H_ | 6 #define CHROMECAST_BROWSER_METRICS_CAST_METRICS_SERVICE_CLIENT_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
| 10 #include <memory> |
10 #include <string> | 11 #include <string> |
11 | 12 |
12 #include "base/macros.h" | 13 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | |
15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
16 #include "components/metrics/metrics_service_client.h" | 16 #include "components/metrics/metrics_service_client.h" |
17 | 17 |
18 class PrefRegistrySimple; | 18 class PrefRegistrySimple; |
19 class PrefService; | 19 class PrefService; |
20 | 20 |
21 namespace base { | 21 namespace base { |
22 class SingleThreadTaskRunner; | 22 class SingleThreadTaskRunner; |
23 class TaskRunner; | 23 class TaskRunner; |
24 } | 24 } |
(...skipping 13 matching lines...) Expand all Loading... |
38 class CastService; | 38 class CastService; |
39 | 39 |
40 namespace metrics { | 40 namespace metrics { |
41 | 41 |
42 class ExternalMetrics; | 42 class ExternalMetrics; |
43 | 43 |
44 class CastMetricsServiceClient : public ::metrics::MetricsServiceClient { | 44 class CastMetricsServiceClient : public ::metrics::MetricsServiceClient { |
45 public: | 45 public: |
46 ~CastMetricsServiceClient() override; | 46 ~CastMetricsServiceClient() override; |
47 | 47 |
48 static scoped_ptr<CastMetricsServiceClient> Create( | 48 static std::unique_ptr<CastMetricsServiceClient> Create( |
49 base::TaskRunner* io_task_runner, | 49 base::TaskRunner* io_task_runner, |
50 PrefService* pref_service, | 50 PrefService* pref_service, |
51 net::URLRequestContextGetter* request_context); | 51 net::URLRequestContextGetter* request_context); |
52 static void RegisterPrefs(PrefRegistrySimple* registry); | 52 static void RegisterPrefs(PrefRegistrySimple* registry); |
53 | 53 |
54 // Use |client_id| when starting MetricsService instead of generating a new | 54 // Use |client_id| when starting MetricsService instead of generating a new |
55 // client ID. If used, SetForceClientId must be called before Initialize. | 55 // client ID. If used, SetForceClientId must be called before Initialize. |
56 void SetForceClientId(const std::string& client_id); | 56 void SetForceClientId(const std::string& client_id); |
57 void OnApplicationNotIdle(); | 57 void OnApplicationNotIdle(); |
58 | 58 |
(...skipping 12 matching lines...) Expand all Loading... |
71 bool IsOffTheRecordSessionActive() override; | 71 bool IsOffTheRecordSessionActive() override; |
72 int32_t GetProduct() override; | 72 int32_t GetProduct() override; |
73 std::string GetApplicationLocale() override; | 73 std::string GetApplicationLocale() override; |
74 bool GetBrand(std::string* brand_code) override; | 74 bool GetBrand(std::string* brand_code) override; |
75 ::metrics::SystemProfileProto::Channel GetChannel() override; | 75 ::metrics::SystemProfileProto::Channel GetChannel() override; |
76 std::string GetVersionString() override; | 76 std::string GetVersionString() override; |
77 void OnLogUploadComplete() override; | 77 void OnLogUploadComplete() override; |
78 void InitializeSystemProfileMetrics( | 78 void InitializeSystemProfileMetrics( |
79 const base::Closure& done_callback) override; | 79 const base::Closure& done_callback) override; |
80 void CollectFinalMetricsForLog(const base::Closure& done_callback) override; | 80 void CollectFinalMetricsForLog(const base::Closure& done_callback) override; |
81 scoped_ptr< ::metrics::MetricsLogUploader> CreateUploader( | 81 std::unique_ptr<::metrics::MetricsLogUploader> CreateUploader( |
82 const base::Callback<void(int)>& on_upload_complete) override; | 82 const base::Callback<void(int)>& on_upload_complete) override; |
83 base::TimeDelta GetStandardUploadInterval() override; | 83 base::TimeDelta GetStandardUploadInterval() override; |
84 | 84 |
85 // Starts/stops the metrics service. | 85 // Starts/stops the metrics service. |
86 void EnableMetricsService(bool enabled); | 86 void EnableMetricsService(bool enabled); |
87 | 87 |
88 std::string client_id() const { return client_id_; } | 88 std::string client_id() const { return client_id_; } |
89 | 89 |
90 private: | 90 private: |
91 CastMetricsServiceClient(base::TaskRunner* io_task_runner, | 91 CastMetricsServiceClient(base::TaskRunner* io_task_runner, |
92 PrefService* pref_service, | 92 PrefService* pref_service, |
93 net::URLRequestContextGetter* request_context); | 93 net::URLRequestContextGetter* request_context); |
94 | 94 |
95 // Returns whether or not metrics reporting is enabled. | 95 // Returns whether or not metrics reporting is enabled. |
96 bool IsReportingEnabled(); | 96 bool IsReportingEnabled(); |
97 | 97 |
98 scoped_ptr< ::metrics::ClientInfo> LoadClientInfo(); | 98 std::unique_ptr<::metrics::ClientInfo> LoadClientInfo(); |
99 void StoreClientInfo(const ::metrics::ClientInfo& client_info); | 99 void StoreClientInfo(const ::metrics::ClientInfo& client_info); |
100 | 100 |
101 base::TaskRunner* const io_task_runner_; | 101 base::TaskRunner* const io_task_runner_; |
102 PrefService* const pref_service_; | 102 PrefService* const pref_service_; |
103 CastService* cast_service_; | 103 CastService* cast_service_; |
104 std::string client_id_; | 104 std::string client_id_; |
105 std::string force_client_id_; | 105 std::string force_client_id_; |
106 bool client_info_loaded_; | 106 bool client_info_loaded_; |
107 | 107 |
108 #if defined(OS_LINUX) | 108 #if defined(OS_LINUX) |
109 ExternalMetrics* external_metrics_; | 109 ExternalMetrics* external_metrics_; |
110 ExternalMetrics* platform_metrics_; | 110 ExternalMetrics* platform_metrics_; |
111 #endif // defined(OS_LINUX) | 111 #endif // defined(OS_LINUX) |
112 const scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 112 const scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
113 scoped_ptr< ::metrics::MetricsStateManager> metrics_state_manager_; | 113 std::unique_ptr<::metrics::MetricsStateManager> metrics_state_manager_; |
114 scoped_ptr< ::metrics::MetricsService> metrics_service_; | 114 std::unique_ptr<::metrics::MetricsService> metrics_service_; |
115 net::URLRequestContextGetter* const request_context_; | 115 net::URLRequestContextGetter* const request_context_; |
116 | 116 |
117 DISALLOW_COPY_AND_ASSIGN(CastMetricsServiceClient); | 117 DISALLOW_COPY_AND_ASSIGN(CastMetricsServiceClient); |
118 }; | 118 }; |
119 | 119 |
120 } // namespace metrics | 120 } // namespace metrics |
121 } // namespace chromecast | 121 } // namespace chromecast |
122 | 122 |
123 #endif // CHROMECAST_BROWSER_METRICS_CAST_METRICS_SERVICE_CLIENT_H_ | 123 #endif // CHROMECAST_BROWSER_METRICS_CAST_METRICS_SERVICE_CLIENT_H_ |
OLD | NEW |