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_METRICS_CAST_METRICS_SERVICE_CLIENT_H_
6 #define CHROMECAST_METRICS_CAST_METRICS_SERVICE_CLIENT_H_
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"
23 class MetricsStateManager;
24 } // namespace metrics
27 class URLRequestContextGetter;
30 namespace chromecast {
33 class CastMetricsServiceClient : public ::metrics::MetricsServiceClient {
35 virtual ~CastMetricsServiceClient();
37 static CastMetricsServiceClient* Create(
38 base::TaskRunner* io_task_runner,
39 PrefService* pref_service,
40 net::URLRequestContextGetter* request_context);
42 // metrics::MetricsServiceClient implementation:
43 virtual void SetMetricsClientId(const std::string& client_id) OVERRIDE;
44 virtual bool IsOffTheRecordSessionActive() OVERRIDE;
45 virtual std::string GetApplicationLocale() OVERRIDE;
46 virtual bool GetBrand(std::string* brand_code) OVERRIDE;
47 virtual ::metrics::SystemProfileProto::Channel GetChannel() OVERRIDE;
48 virtual std::string GetVersionString() OVERRIDE;
49 virtual void OnLogUploadComplete() OVERRIDE;
50 virtual void StartGatheringMetrics(
51 const base::Closure& done_callback) OVERRIDE;
52 virtual void CollectFinalMetrics(const base::Closure& done_callback) OVERRIDE;
53 virtual scoped_ptr< ::metrics::MetricsLogUploader> CreateUploader(
54 const std::string& server_url,
55 const std::string& mime_type,
56 const base::Callback<void(int)>& on_upload_complete) OVERRIDE;
58 // Starts/stops the metrics service.
59 void EnableMetricsService(bool enabled);
62 CastMetricsServiceClient(
63 base::TaskRunner* io_task_runner,
64 PrefService* pref_service,
65 net::URLRequestContextGetter* request_context);
67 // Returns whether or not metrics reporting is enabled.
68 bool IsReportingEnabled();
70 scoped_ptr< ::metrics::MetricsStateManager> metrics_state_manager_;
71 scoped_ptr< ::metrics::MetricsService> metrics_service_;
72 net::URLRequestContextGetter* request_context_;
74 DISALLOW_COPY_AND_ASSIGN(CastMetricsServiceClient);
77 } // namespace metrics
78 } // namespace chromecast
80 #endif // CHROMECAST_METRICS_CAST_METRICS_SERVICE_CLIENT_H_