Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / chromecast / browser / metrics / cast_metrics_service_client.h
blobec021a2bf6cc596f5369846d8f9ce8703b9c38c7
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
3 // found in the LICENSE file.
5 #ifndef CHROMECAST_BROWSER_METRICS_CAST_METRICS_SERVICE_CLIENT_H_
6 #define CHROMECAST_BROWSER_METRICS_CAST_METRICS_SERVICE_CLIENT_H_
8 #include <string>
10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "components/metrics/metrics_service_client.h"
15 class PrefRegistrySimple;
16 class PrefService;
18 namespace base {
19 class SingleThreadTaskRunner;
20 class TaskRunner;
23 namespace metrics {
24 struct ClientInfo;
25 class MetricsService;
26 class MetricsStateManager;
27 } // namespace metrics
29 namespace net {
30 class URLRequestContextGetter;
31 } // namespace net
33 namespace chromecast {
35 class CastService;
37 namespace metrics {
39 class ExternalMetrics;
41 class CastMetricsServiceClient : public ::metrics::MetricsServiceClient {
42 public:
43 ~CastMetricsServiceClient() override;
45 static scoped_ptr<CastMetricsServiceClient> Create(
46 base::TaskRunner* io_task_runner,
47 PrefService* pref_service,
48 net::URLRequestContextGetter* request_context);
49 static void RegisterPrefs(PrefRegistrySimple* registry);
51 void Initialize(CastService* cast_service);
52 void Finalize();
54 // metrics::MetricsServiceClient implementation:
55 void SetMetricsClientId(const std::string& client_id) override;
56 void OnRecordingDisabled() override;
57 bool IsOffTheRecordSessionActive() override;
58 int32_t GetProduct() override;
59 std::string GetApplicationLocale() override;
60 bool GetBrand(std::string* brand_code) override;
61 ::metrics::SystemProfileProto::Channel GetChannel() override;
62 std::string GetVersionString() override;
63 void OnLogUploadComplete() override;
64 void StartGatheringMetrics(const base::Closure& done_callback) override;
65 void CollectFinalMetrics(const base::Closure& done_callback) override;
66 scoped_ptr< ::metrics::MetricsLogUploader> CreateUploader(
67 const base::Callback<void(int)>& on_upload_complete) override;
68 base::TimeDelta GetStandardUploadInterval() override;
70 // Starts/stops the metrics service.
71 void EnableMetricsService(bool enabled);
73 std::string client_id() const {
74 return client_id_;
77 private:
78 CastMetricsServiceClient(
79 base::TaskRunner* io_task_runner,
80 PrefService* pref_service,
81 net::URLRequestContextGetter* request_context);
83 // Returns whether or not metrics reporting is enabled.
84 bool IsReportingEnabled();
86 scoped_ptr< ::metrics::ClientInfo> LoadClientInfo();
87 void StoreClientInfo(const ::metrics::ClientInfo& client_info);
89 base::TaskRunner* const io_task_runner_;
90 PrefService* const pref_service_;
91 CastService* cast_service_;
92 std::string client_id_;
94 #if defined(OS_LINUX)
95 ExternalMetrics* external_metrics_;
96 #endif // defined(OS_LINUX)
97 const scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
98 scoped_ptr< ::metrics::MetricsStateManager> metrics_state_manager_;
99 scoped_ptr< ::metrics::MetricsService> metrics_service_;
100 net::URLRequestContextGetter* const request_context_;
102 DISALLOW_COPY_AND_ASSIGN(CastMetricsServiceClient);
105 } // namespace metrics
106 } // namespace chromecast
108 #endif // CHROMECAST_BROWSER_METRICS_CAST_METRICS_SERVICE_CLIENT_H_