11320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// Copyright 2014 The Chromium Authors. All rights reserved.
21320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// Use of this source code is governed by a BSD-style license that can be
31320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// found in the LICENSE file.
41320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
51320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#ifndef CHROMECAST_METRICS_CAST_METRICS_SERVICE_CLIENT_H_
61320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#define CHROMECAST_METRICS_CAST_METRICS_SERVICE_CLIENT_H_
71320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
81320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include <string>
91320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
101320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "base/macros.h"
111320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "base/memory/ref_counted.h"
121320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "base/memory/scoped_ptr.h"
131320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "components/metrics/metrics_service_client.h"
141320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
151320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciclass PrefService;
161320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
171320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccinamespace base {
181320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciclass TaskRunner;
191320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}
201320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
211320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccinamespace metrics {
221320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciclass MetricsService;
231320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciclass MetricsStateManager;
241320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}  // namespace metrics
251320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
261320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccinamespace net {
271320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciclass URLRequestContextGetter;
281320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}  // namespace net
291320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
301320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccinamespace chromecast {
311320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccinamespace metrics {
321320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
331320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciclass CastMetricsServiceClient : public ::metrics::MetricsServiceClient {
341320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci public:
351320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual ~CastMetricsServiceClient();
361320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
371320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  static CastMetricsServiceClient* Create(
381320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      base::TaskRunner* io_task_runner,
391320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      PrefService* pref_service,
401320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      net::URLRequestContextGetter* request_context);
411320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
421320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // metrics::MetricsServiceClient implementation:
431320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual void SetMetricsClientId(const std::string& client_id) OVERRIDE;
441320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual bool IsOffTheRecordSessionActive() OVERRIDE;
451320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual std::string GetApplicationLocale() OVERRIDE;
461320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual bool GetBrand(std::string* brand_code) OVERRIDE;
471320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual ::metrics::SystemProfileProto::Channel GetChannel() OVERRIDE;
481320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual std::string GetVersionString() OVERRIDE;
491320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual void OnLogUploadComplete() OVERRIDE;
501320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual void StartGatheringMetrics(
511320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      const base::Closure& done_callback) OVERRIDE;
521320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual void CollectFinalMetrics(const base::Closure& done_callback) OVERRIDE;
531320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual scoped_ptr< ::metrics::MetricsLogUploader> CreateUploader(
541320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      const std::string& server_url,
551320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      const std::string& mime_type,
561320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      const base::Callback<void(int)>& on_upload_complete) OVERRIDE;
571320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
581320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // Starts/stops the metrics service.
591320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  void EnableMetricsService(bool enabled);
601320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
611320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci private:
621320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  CastMetricsServiceClient(
631320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      base::TaskRunner* io_task_runner,
641320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      PrefService* pref_service,
651320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      net::URLRequestContextGetter* request_context);
661320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
671320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // Returns whether or not metrics reporting is enabled.
681320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  bool IsReportingEnabled();
691320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
701320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  scoped_ptr< ::metrics::MetricsStateManager> metrics_state_manager_;
711320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  scoped_ptr< ::metrics::MetricsService> metrics_service_;
721320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  net::URLRequestContextGetter* request_context_;
731320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
741320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  DISALLOW_COPY_AND_ASSIGN(CastMetricsServiceClient);
751320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci};
761320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
771320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}  // namespace metrics
781320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}  // namespace chromecast
791320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
801320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#endif  // CHROMECAST_METRICS_CAST_METRICS_SERVICE_CLIENT_H_
81