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 COMPONENTS_METRICS_METRICS_SERVICE_CLIENT_H_
6 #define COMPONENTS_METRICS_METRICS_SERVICE_CLIENT_H_
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 "base/time/time.h"
16 #include "components/metrics/proto/system_profile.pb.h"
20 class MetricsLogUploader
;
22 // An abstraction of operations that depend on the embedder's (e.g. Chrome)
24 class MetricsServiceClient
{
26 virtual ~MetricsServiceClient() {}
28 // Registers the client id with other services (e.g. crash reporting), called
29 // when metrics recording gets enabled.
30 virtual void SetMetricsClientId(const std::string
& client_id
) = 0;
32 // Notifies the client that recording is disabled, so that other services
33 // (such as crash reporting) can clear any association with metrics.
34 virtual void OnRecordingDisabled() = 0;
36 // Whether there's an "off the record" (aka "Incognito") session active.
37 virtual bool IsOffTheRecordSessionActive() = 0;
39 // Returns the product value to use in uploaded reports, which will be used to
40 // set the ChromeUserMetricsExtension.product field. See comments on that
41 // field on why it's an int32 rather than an enum.
42 virtual int32_t GetProduct() = 0;
44 // Returns the current application locale (e.g. "en-US").
45 virtual std::string
GetApplicationLocale() = 0;
47 // Retrieves the brand code string associated with the install, returning
48 // false if no brand code is available.
49 virtual bool GetBrand(std::string
* brand_code
) = 0;
51 // Returns the release channel (e.g. stable, beta, etc) of the application.
52 virtual SystemProfileProto::Channel
GetChannel() = 0;
54 // Returns the version of the application as a string.
55 virtual std::string
GetVersionString() = 0;
57 // Called by the metrics service when a log has been uploaded.
58 virtual void OnLogUploadComplete() = 0;
60 // Starts gathering metrics, calling |done_callback| when initial metrics
61 // gathering is complete.
62 virtual void StartGatheringMetrics(const base::Closure
& done_callback
) = 0;
64 // Called prior to a metrics log being closed, allowing the client to collect
65 // extra histograms that will go in that log. Asynchronous API - the client
66 // implementation should call |done_callback| when complete.
67 virtual void CollectFinalMetrics(const base::Closure
& done_callback
) = 0;
69 // Creates a MetricsLogUploader with the specified parameters (see comments on
70 // MetricsLogUploader for details).
71 virtual scoped_ptr
<MetricsLogUploader
> CreateUploader(
72 const base::Callback
<void(int)>& on_upload_complete
) = 0;
74 // Returns the standard interval between upload attempts.
75 virtual base::TimeDelta
GetStandardUploadInterval() = 0;
77 // Returns the name of a key under HKEY_CURRENT_USER that can be used to store
78 // backups of metrics data. Unused except on Windows.
79 virtual base::string16
GetRegistryBackupKey();
82 } // namespace metrics
84 #endif // COMPONENTS_METRICS_METRICS_SERVICE_CLIENT_H_