Update To 11.40.268.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 <stdint.h>
9 #include <string>
10
11 #include "base/basictypes.h"
12 #include "base/callback_forward.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/strings/string16.h"
15 #include "components/metrics/proto/system_profile.pb.h"
16
17 namespace metrics {
18
19 class MetricsLogUploader;
20
21 // An abstraction of operations that depend on the embedder's (e.g. Chrome)
22 // environment.
23 class MetricsServiceClient {
24  public:
25   virtual ~MetricsServiceClient() {}
26
27   // Registers the client id with other services (e.g. crash reporting), called
28   // when metrics recording gets enabled.
29   virtual void SetMetricsClientId(const std::string& client_id) = 0;
30
31   // Whether there's an "off the record" (aka "Incognito") session active.
32   virtual bool IsOffTheRecordSessionActive() = 0;
33
34   // Returns the product value to use in uploaded reports, which will be used to
35   // set the ChromeUserMetricsExtension.product field. See comments on that
36   // field on why it's an int32 rather than an enum.
37   virtual int32_t GetProduct() = 0;
38
39   // Returns the current application locale (e.g. "en-US").
40   virtual std::string GetApplicationLocale() = 0;
41
42   // Retrieves the brand code string associated with the install, returning
43   // false if no brand code is available.
44   virtual bool GetBrand(std::string* brand_code) = 0;
45
46   // Returns the release channel (e.g. stable, beta, etc) of the application.
47   virtual SystemProfileProto::Channel GetChannel() = 0;
48
49   // Returns the version of the application as a string.
50   virtual std::string GetVersionString() = 0;
51
52   // Called by the metrics service when a log has been uploaded.
53   virtual void OnLogUploadComplete() = 0;
54
55   // Starts gathering metrics, calling |done_callback| when initial metrics
56   // gathering is complete.
57   virtual void StartGatheringMetrics(const base::Closure& done_callback) = 0;
58
59   // Called prior to a metrics log being closed, allowing the client to collect
60   // extra histograms that will go in that log. Asynchronous API - the client
61   // implementation should call |done_callback| when complete.
62   virtual void CollectFinalMetrics(const base::Closure& done_callback) = 0;
63
64   // Creates a MetricsLogUploader with the specified parameters (see comments on
65   // MetricsLogUploader for details).
66   virtual scoped_ptr<MetricsLogUploader> CreateUploader(
67       const std::string& server_url,
68       const std::string& mime_type,
69       const base::Callback<void(int)>& on_upload_complete) = 0;
70
71   // Returns the name of a key under HKEY_CURRENT_USER that can be used to store
72   // backups of metrics data. Unused except on Windows.
73   virtual base::string16 GetRegistryBackupKey();
74 };
75
76 }  // namespace metrics
77
78 #endif  // COMPONENTS_METRICS_METRICS_SERVICE_CLIENT_H_