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_METRICS_CAST_METRICS_SERVICE_CLIENT_H_ | 5 #ifndef CHROMECAST_METRICS_CAST_METRICS_SERVICE_CLIENT_H_ |
6 #define CHROMECAST_METRICS_CAST_METRICS_SERVICE_CLIENT_H_ | 6 #define CHROMECAST_METRICS_CAST_METRICS_SERVICE_CLIENT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "components/metrics/metrics_service_client.h" | 13 #include "components/metrics/metrics_service_client.h" |
14 | 14 |
15 class PrefService; | 15 class PrefService; |
16 | 16 |
| 17 namespace base { |
| 18 class TaskRunner; |
| 19 } |
| 20 |
17 namespace metrics { | 21 namespace metrics { |
18 class MetricsService; | 22 class MetricsService; |
19 class MetricsStateManager; | 23 class MetricsStateManager; |
20 } // namespace metrics | 24 } // namespace metrics |
21 | 25 |
22 namespace net { | 26 namespace net { |
23 class URLRequestContextGetter; | 27 class URLRequestContextGetter; |
24 } // namespace net | 28 } // namespace net |
25 | 29 |
26 namespace chromecast { | 30 namespace chromecast { |
27 namespace metrics { | 31 namespace metrics { |
28 | 32 |
29 class CastMetricsServiceClient : public ::metrics::MetricsServiceClient { | 33 class CastMetricsServiceClient : public ::metrics::MetricsServiceClient { |
30 public: | 34 public: |
31 virtual ~CastMetricsServiceClient(); | 35 virtual ~CastMetricsServiceClient(); |
32 | 36 |
33 static CastMetricsServiceClient* Create( | 37 static CastMetricsServiceClient* Create( |
| 38 base::TaskRunner* io_task_runner, |
34 PrefService* pref_service, | 39 PrefService* pref_service, |
35 net::URLRequestContextGetter* request_context); | 40 net::URLRequestContextGetter* request_context); |
36 | 41 |
37 // metrics::MetricsServiceClient implementation: | 42 // metrics::MetricsServiceClient implementation: |
38 virtual void SetMetricsClientId(const std::string& client_id) OVERRIDE; | 43 virtual void SetMetricsClientId(const std::string& client_id) OVERRIDE; |
39 virtual bool IsOffTheRecordSessionActive() OVERRIDE; | 44 virtual bool IsOffTheRecordSessionActive() OVERRIDE; |
40 virtual std::string GetApplicationLocale() OVERRIDE; | 45 virtual std::string GetApplicationLocale() OVERRIDE; |
41 virtual bool GetBrand(std::string* brand_code) OVERRIDE; | 46 virtual bool GetBrand(std::string* brand_code) OVERRIDE; |
42 virtual ::metrics::SystemProfileProto::Channel GetChannel() OVERRIDE; | 47 virtual ::metrics::SystemProfileProto::Channel GetChannel() OVERRIDE; |
43 virtual std::string GetVersionString() OVERRIDE; | 48 virtual std::string GetVersionString() OVERRIDE; |
44 virtual void OnLogUploadComplete() OVERRIDE; | 49 virtual void OnLogUploadComplete() OVERRIDE; |
45 virtual void StartGatheringMetrics( | 50 virtual void StartGatheringMetrics( |
46 const base::Closure& done_callback) OVERRIDE; | 51 const base::Closure& done_callback) OVERRIDE; |
47 virtual void CollectFinalMetrics(const base::Closure& done_callback) OVERRIDE; | 52 virtual void CollectFinalMetrics(const base::Closure& done_callback) OVERRIDE; |
48 virtual scoped_ptr< ::metrics::MetricsLogUploader> CreateUploader( | 53 virtual scoped_ptr< ::metrics::MetricsLogUploader> CreateUploader( |
49 const std::string& server_url, | 54 const std::string& server_url, |
50 const std::string& mime_type, | 55 const std::string& mime_type, |
51 const base::Callback<void(int)>& on_upload_complete) OVERRIDE; | 56 const base::Callback<void(int)>& on_upload_complete) OVERRIDE; |
52 | 57 |
53 // Starts/stops the metrics service. | 58 // Starts/stops the metrics service. |
54 void EnableMetricsService(bool enabled); | 59 void EnableMetricsService(bool enabled); |
55 | 60 |
56 private: | 61 private: |
57 CastMetricsServiceClient( | 62 CastMetricsServiceClient( |
| 63 base::TaskRunner* io_task_runner, |
58 PrefService* pref_service, | 64 PrefService* pref_service, |
59 net::URLRequestContextGetter* request_context); | 65 net::URLRequestContextGetter* request_context); |
60 | 66 |
61 // Returns whether or not metrics reporting is enabled. | 67 // Returns whether or not metrics reporting is enabled. |
62 bool IsReportingEnabled(); | 68 bool IsReportingEnabled(); |
63 | 69 |
64 scoped_ptr< ::metrics::MetricsStateManager> metrics_state_manager_; | 70 scoped_ptr< ::metrics::MetricsStateManager> metrics_state_manager_; |
65 scoped_ptr< ::metrics::MetricsService> metrics_service_; | 71 scoped_ptr< ::metrics::MetricsService> metrics_service_; |
66 net::URLRequestContextGetter* request_context_; | 72 net::URLRequestContextGetter* request_context_; |
67 | 73 |
68 DISALLOW_COPY_AND_ASSIGN(CastMetricsServiceClient); | 74 DISALLOW_COPY_AND_ASSIGN(CastMetricsServiceClient); |
69 }; | 75 }; |
70 | 76 |
71 } // namespace metrics | 77 } // namespace metrics |
72 } // namespace chromecast | 78 } // namespace chromecast |
73 | 79 |
74 #endif // CHROMECAST_METRICS_CAST_METRICS_SERVICE_CLIENT_H_ | 80 #endif // CHROMECAST_METRICS_CAST_METRICS_SERVICE_CLIENT_H_ |
OLD | NEW |