Make Ctrl + T from apps focus the new tab's omnibox on Linux and ChromeOS.
[chromium-blink-merge.git] / chromecast / browser / metrics / cast_metrics_service_client.h
blobabc2b57311c5141d4f62052f2cb06d67e60cede9
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 PrefService;
17 namespace base {
18 class MessageLoopProxy;
19 class TaskRunner;
22 namespace metrics {
23 struct ClientInfo;
24 class MetricsService;
25 class MetricsStateManager;
26 } // namespace metrics
28 namespace net {
29 class URLRequestContextGetter;
30 } // namespace net
32 namespace chromecast {
34 class CastService;
36 namespace metrics {
38 class ExternalMetrics;
40 class CastMetricsServiceClient : public ::metrics::MetricsServiceClient {
41 public:
42 ~CastMetricsServiceClient() override;
44 static scoped_ptr<CastMetricsServiceClient> Create(
45 base::TaskRunner* io_task_runner,
46 PrefService* pref_service,
47 net::URLRequestContextGetter* request_context);
49 void Initialize(CastService* cast_service);
50 void Finalize();
52 // metrics::MetricsServiceClient implementation:
53 void SetMetricsClientId(const std::string& client_id) override;
54 void OnRecordingDisabled() override;
55 bool IsOffTheRecordSessionActive() override;
56 int32_t GetProduct() override;
57 std::string GetApplicationLocale() override;
58 bool GetBrand(std::string* brand_code) override;
59 ::metrics::SystemProfileProto::Channel GetChannel() override;
60 std::string GetVersionString() override;
61 void OnLogUploadComplete() override;
62 void StartGatheringMetrics(const base::Closure& done_callback) override;
63 void CollectFinalMetrics(const base::Closure& done_callback) override;
64 scoped_ptr< ::metrics::MetricsLogUploader> CreateUploader(
65 const base::Callback<void(int)>& on_upload_complete) override;
66 base::TimeDelta GetStandardUploadInterval() override;
68 // Starts/stops the metrics service.
69 void EnableMetricsService(bool enabled);
71 std::string client_id() const {
72 return client_id_;
75 private:
76 CastMetricsServiceClient(
77 base::TaskRunner* io_task_runner,
78 PrefService* pref_service,
79 net::URLRequestContextGetter* request_context);
81 // Returns whether or not metrics reporting is enabled.
82 bool IsReportingEnabled();
84 scoped_ptr< ::metrics::ClientInfo> LoadClientInfo();
85 void StoreClientInfo(const ::metrics::ClientInfo& client_info);
87 base::TaskRunner* const io_task_runner_;
88 PrefService* const pref_service_;
89 CastService* cast_service_;
90 std::string client_id_;
92 #if defined(OS_LINUX)
93 ExternalMetrics* external_metrics_;
94 #endif // defined(OS_LINUX)
95 const scoped_refptr<base::MessageLoopProxy> metrics_service_loop_;
96 scoped_ptr< ::metrics::MetricsStateManager> metrics_state_manager_;
97 scoped_ptr< ::metrics::MetricsService> metrics_service_;
98 net::URLRequestContextGetter* const request_context_;
100 DISALLOW_COPY_AND_ASSIGN(CastMetricsServiceClient);
103 } // namespace metrics
104 } // namespace chromecast
106 #endif // CHROMECAST_BROWSER_METRICS_CAST_METRICS_SERVICE_CLIENT_H_