OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 BLIMP_ENGINE_APP_BLIMP_METRICS_SERVICE_CLIENT_H_ | 5 #ifndef BLIMP_ENGINE_APP_BLIMP_METRICS_SERVICE_CLIENT_H_ |
6 #define BLIMP_ENGINE_APP_BLIMP_METRICS_SERVICE_CLIENT_H_ | 6 #define BLIMP_ENGINE_APP_BLIMP_METRICS_SERVICE_CLIENT_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "components/metrics/enabled_state_provider.h" | |
14 #include "components/metrics/metrics_service_client.h" | 15 #include "components/metrics/metrics_service_client.h" |
15 | 16 |
16 class PrefService; | 17 class PrefService; |
17 | 18 |
18 namespace metrics { | 19 namespace metrics { |
19 class MetricsService; | 20 class MetricsService; |
20 class MetricsStateManager; | 21 class MetricsStateManager; |
21 class SystemProfileProto; | 22 class SystemProfileProto; |
22 } | 23 } |
23 | 24 |
24 namespace net { | 25 namespace net { |
25 class URLRequestContextGetter; | 26 class URLRequestContextGetter; |
26 } // namespace net | 27 } // namespace net |
27 | 28 |
28 namespace blimp { | 29 namespace blimp { |
29 namespace engine { | 30 namespace engine { |
30 | 31 |
31 // BlimpMetricsServiceClient provides an implementation of MetricsServiceClient | 32 // BlimpMetricsServiceClient provides an implementation of MetricsServiceClient |
32 // tailored for the Blimp engine to support the upload of metrics information | 33 // tailored for the Blimp engine to support the upload of metrics information |
33 // from the engine. | 34 // from the engine. |
34 // Metrics are always turned on. | 35 // Metrics are always turned on. |
35 class BlimpMetricsServiceClient : public metrics::MetricsServiceClient { | 36 class BlimpMetricsServiceClient : public metrics::MetricsServiceClient, |
37 public metrics::EnabledStateProvider { | |
36 public: | 38 public: |
37 // PrefService ownership is retained by the caller. | 39 // PrefService ownership is retained by the caller. |
38 // The request_context_getter is a system request context. | 40 // The request_context_getter is a system request context. |
39 // Both must remain valid for client lifetime. | 41 // Both must remain valid for client lifetime. |
40 BlimpMetricsServiceClient( | 42 BlimpMetricsServiceClient( |
41 PrefService* pref_service, | 43 PrefService* pref_service, |
42 scoped_refptr<net::URLRequestContextGetter> request_context_getter); | 44 scoped_refptr<net::URLRequestContextGetter> request_context_getter); |
43 ~BlimpMetricsServiceClient() override; | 45 ~BlimpMetricsServiceClient() override; |
44 | 46 |
45 // metrics::MetricsServiceClient implementation. | 47 // metrics::MetricsServiceClient implementation. |
46 metrics::MetricsService* GetMetricsService() override; | 48 metrics::MetricsService* GetMetricsService() override; |
47 void SetMetricsClientId(const std::string& client_id) override; | 49 void SetMetricsClientId(const std::string& client_id) override; |
48 void OnRecordingDisabled() override; | 50 void OnRecordingDisabled() override; |
49 bool IsOffTheRecordSessionActive() override; | 51 bool IsOffTheRecordSessionActive() override; |
50 int32_t GetProduct() override; | 52 int32_t GetProduct() override; |
51 std::string GetApplicationLocale() override; | 53 std::string GetApplicationLocale() override; |
52 bool GetBrand(std::string* brand_code) override; | 54 bool GetBrand(std::string* brand_code) override; |
53 metrics::SystemProfileProto::Channel GetChannel() override; | 55 metrics::SystemProfileProto::Channel GetChannel() override; |
54 std::string GetVersionString() override; | 56 std::string GetVersionString() override; |
55 void OnLogUploadComplete() override; | 57 void OnLogUploadComplete() override; |
56 void InitializeSystemProfileMetrics( | 58 void InitializeSystemProfileMetrics( |
57 const base::Closure& done_callback) override; | 59 const base::Closure& done_callback) override; |
58 void CollectFinalMetricsForLog(const base::Closure& done_callback) override; | 60 void CollectFinalMetricsForLog(const base::Closure& done_callback) override; |
59 std::unique_ptr<metrics::MetricsLogUploader> CreateUploader( | 61 std::unique_ptr<metrics::MetricsLogUploader> CreateUploader( |
60 const base::Callback<void(int)>& on_upload_complete) override; | 62 const base::Callback<void(int)>& on_upload_complete) override; |
61 base::TimeDelta GetStandardUploadInterval() override; | 63 base::TimeDelta GetStandardUploadInterval() override; |
62 metrics::MetricsServiceClient::EnableMetricsDefault GetDefaultOptIn() | 64 metrics::MetricsServiceClient::EnableMetricsDefault GetDefaultOptIn() |
63 override; | 65 override; |
64 | 66 |
67 // metrics::EnabledStateProvider: | |
Kevin M
2016/05/12 17:58:46
nit: "metrics::EnabledStateProvider implementation
jwd
2016/05/12 18:09:45
Done.
| |
68 // Returns if consent is given for the MetricsService to record metrics | |
69 // information for the client. Always true. | |
70 bool IsConsentGiven() override; | |
71 | |
65 private: | 72 private: |
66 // Used by NetMetricsLogUploader to create log-upload requests. | 73 // Used by NetMetricsLogUploader to create log-upload requests. |
67 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; | 74 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; |
68 | 75 |
69 std::unique_ptr<metrics::MetricsStateManager> metrics_state_manager_; | 76 std::unique_ptr<metrics::MetricsStateManager> metrics_state_manager_; |
70 std::unique_ptr<metrics::MetricsService> metrics_service_; | 77 std::unique_ptr<metrics::MetricsService> metrics_service_; |
71 | 78 |
72 DISALLOW_COPY_AND_ASSIGN(BlimpMetricsServiceClient); | 79 DISALLOW_COPY_AND_ASSIGN(BlimpMetricsServiceClient); |
73 }; | 80 }; |
74 | 81 |
75 } // namespace engine | 82 } // namespace engine |
76 } // namespace blimp | 83 } // namespace blimp |
77 | 84 |
78 #endif // BLIMP_ENGINE_APP_BLIMP_METRICS_SERVICE_CLIENT_H_ | 85 #endif // BLIMP_ENGINE_APP_BLIMP_METRICS_SERVICE_CLIENT_H_ |
OLD | NEW |