Update CrOS OOBE throbber to MD throbber; delete old asset
[chromium-blink-merge.git] / chromecast / browser / metrics / cast_metrics_service_client.h
blobbbc22442c9601f195ca704ee61f4388011354081
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 // Use |client_id| when starting MetricsService instead of generating a new
52 // client ID. If used, SetForceClientId must be called before Initialize.
53 void SetForceClientId(const std::string& client_id);
54 void OnApplicationNotIdle();
56 void Initialize(CastService* cast_service);
57 void Finalize();
59 // metrics::MetricsServiceClient implementation:
60 void SetMetricsClientId(const std::string& client_id) override;
61 void OnRecordingDisabled() override;
62 bool IsOffTheRecordSessionActive() override;
63 int32_t GetProduct() override;
64 std::string GetApplicationLocale() override;
65 bool GetBrand(std::string* brand_code) override;
66 ::metrics::SystemProfileProto::Channel GetChannel() override;
67 std::string GetVersionString() override;
68 void OnLogUploadComplete() override;
69 void StartGatheringMetrics(const base::Closure& done_callback) override;
70 void CollectFinalMetrics(const base::Closure& done_callback) override;
71 scoped_ptr< ::metrics::MetricsLogUploader> CreateUploader(
72 const base::Callback<void(int)>& on_upload_complete) override;
73 base::TimeDelta GetStandardUploadInterval() override;
75 // Starts/stops the metrics service.
76 void EnableMetricsService(bool enabled);
78 std::string client_id() const { return client_id_; }
80 private:
81 CastMetricsServiceClient(base::TaskRunner* io_task_runner,
82 PrefService* pref_service,
83 net::URLRequestContextGetter* request_context);
85 // Returns whether or not metrics reporting is enabled.
86 bool IsReportingEnabled();
88 scoped_ptr< ::metrics::ClientInfo> LoadClientInfo();
89 void StoreClientInfo(const ::metrics::ClientInfo& client_info);
91 base::TaskRunner* const io_task_runner_;
92 PrefService* const pref_service_;
93 CastService* cast_service_;
94 std::string client_id_;
95 std::string force_client_id_;
96 bool client_info_loaded_;
98 #if defined(OS_LINUX)
99 ExternalMetrics* external_metrics_;
100 ExternalMetrics* platform_metrics_;
101 #endif // defined(OS_LINUX)
102 const scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
103 scoped_ptr< ::metrics::MetricsStateManager> metrics_state_manager_;
104 scoped_ptr< ::metrics::MetricsService> metrics_service_;
105 net::URLRequestContextGetter* const request_context_;
107 DISALLOW_COPY_AND_ASSIGN(CastMetricsServiceClient);
110 } // namespace metrics
111 } // namespace chromecast
113 #endif // CHROMECAST_BROWSER_METRICS_CAST_METRICS_SERVICE_CLIENT_H_