Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / components / metrics / metrics_service_client.h
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.
4
5 #ifndef COMPONENTS_METRICS_METRICS_SERVICE_CLIENT_H_
6 #define COMPONENTS_METRICS_METRICS_SERVICE_CLIENT_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/callback_forward.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "components/metrics/proto/system_profile.pb.h"
14
15 namespace metrics {
16
17 class MetricsLogUploader;
18
19 // An abstraction of operations that depend on the embedder's (e.g. Chrome)
20 // environment.
21 class MetricsServiceClient {
22  public:
23   virtual ~MetricsServiceClient() {}
24
25   // Registers the client id with other services (e.g. crash reporting), called
26   // when metrics recording gets enabled.
27   virtual void SetMetricsClientId(const std::string& client_id) = 0;
28
29   // Whether there's an "off the record" (aka "Incognito") session active.
30   virtual bool IsOffTheRecordSessionActive() = 0;
31
32   // Returns the current application locale (e.g. "en-US").
33   virtual std::string GetApplicationLocale() = 0;
34
35   // Retrieves the brand code string associated with the install, returning
36   // false if no brand code is available.
37   virtual bool GetBrand(std::string* brand_code) = 0;
38
39   // Returns the release channel (e.g. stable, beta, etc) of the application.
40   virtual SystemProfileProto::Channel GetChannel() = 0;
41
42   // Returns the version of the application as a string.
43   virtual std::string GetVersionString() = 0;
44
45   // Called by the metrics service when a log has been uploaded.
46   virtual void OnLogUploadComplete() = 0;
47
48   // Starts gathering metrics, calling |done_callback| when initial metrics
49   // gathering is complete.
50   virtual void StartGatheringMetrics(const base::Closure& done_callback) = 0;
51
52   // Called prior to a metrics log being closed, allowing the client to collect
53   // extra histograms that will go in that log. Asynchronous API - the client
54   // implementation should call |done_callback| when complete.
55   virtual void CollectFinalMetrics(const base::Closure& done_callback) = 0;
56
57   // Creates a MetricsLogUploader with the specified parameters (see comments on
58   // MetricsLogUploader for details).
59   virtual scoped_ptr<MetricsLogUploader> CreateUploader(
60       const std::string& server_url,
61       const std::string& mime_type,
62       const base::Callback<void(int)>& on_upload_complete) = 0;
63 };
64
65 }  // namespace metrics
66
67 #endif  // COMPONENTS_METRICS_METRICS_SERVICE_CLIENT_H_