| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_METRICS_METRICS_SERVICE_CLIENT_H_ | 5 #ifndef COMPONENTS_METRICS_METRICS_SERVICE_CLIENT_H_ |
| 6 #define COMPONENTS_METRICS_METRICS_SERVICE_CLIENT_H_ | 6 #define COMPONENTS_METRICS_METRICS_SERVICE_CLIENT_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
| 14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
| 15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "components/metrics/metrics_reporting_default_state.h" | 16 #include "components/metrics/metrics_reporting_default_state.h" |
| 17 #include "components/metrics/proto/system_profile.pb.h" | 17 #include "components/metrics/proto/system_profile.pb.h" |
| 18 | 18 |
| 19 namespace base { | 19 namespace base { |
| 20 class FilePath; | 20 class FilePath; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace ukm { |
| 24 class UkmService; |
| 25 } |
| 26 |
| 23 namespace metrics { | 27 namespace metrics { |
| 24 | 28 |
| 25 class MetricsLogUploader; | 29 class MetricsLogUploader; |
| 26 class MetricsService; | 30 class MetricsService; |
| 27 | 31 |
| 28 // An abstraction of operations that depend on the embedder's (e.g. Chrome) | 32 // An abstraction of operations that depend on the embedder's (e.g. Chrome) |
| 29 // environment. | 33 // environment. |
| 30 class MetricsServiceClient { | 34 class MetricsServiceClient { |
| 31 public: | 35 public: |
| 32 virtual ~MetricsServiceClient() {} | 36 virtual ~MetricsServiceClient() {} |
| 33 | 37 |
| 34 // Returns the MetricsService instance that this client is associated with. | 38 // Returns the MetricsService instance that this client is associated with. |
| 35 // With the exception of testing contexts, the returned instance must be valid | 39 // With the exception of testing contexts, the returned instance must be valid |
| 36 // for the lifetime of this object (typically, the embedder's client | 40 // for the lifetime of this object (typically, the embedder's client |
| 37 // implementation will own the MetricsService instance being returned). | 41 // implementation will own the MetricsService instance being returned). |
| 38 virtual MetricsService* GetMetricsService() = 0; | 42 virtual MetricsService* GetMetricsService() = 0; |
| 39 | 43 |
| 44 // Returns the UkmService instance that this client is associated with. |
| 45 virtual ukm::UkmService* GetUkmService() = 0; |
| 46 |
| 40 // Registers the client id with other services (e.g. crash reporting), called | 47 // Registers the client id with other services (e.g. crash reporting), called |
| 41 // when metrics recording gets enabled. | 48 // when metrics recording gets enabled. |
| 42 virtual void SetMetricsClientId(const std::string& client_id) = 0; | 49 virtual void SetMetricsClientId(const std::string& client_id) = 0; |
| 43 | 50 |
| 44 // Returns the product value to use in uploaded reports, which will be used to | 51 // Returns the product value to use in uploaded reports, which will be used to |
| 45 // set the ChromeUserMetricsExtension.product field. See comments on that | 52 // set the ChromeUserMetricsExtension.product field. See comments on that |
| 46 // field on why it's an int32_t rather than an enum. | 53 // field on why it's an int32_t rather than an enum. |
| 47 virtual int32_t GetProduct() = 0; | 54 virtual int32_t GetProduct() = 0; |
| 48 | 55 |
| 49 // Returns the current application locale (e.g. "en-US"). | 56 // Returns the current application locale (e.g. "en-US"). |
| (...skipping 28 matching lines...) Expand all Loading... |
| 78 | 85 |
| 79 // Called prior to a metrics log being closed, allowing the client to collect | 86 // Called prior to a metrics log being closed, allowing the client to collect |
| 80 // extra histograms that will go in that log. Asynchronous API - the client | 87 // extra histograms that will go in that log. Asynchronous API - the client |
| 81 // implementation should call |done_callback| when complete. | 88 // implementation should call |done_callback| when complete. |
| 82 virtual void CollectFinalMetricsForLog( | 89 virtual void CollectFinalMetricsForLog( |
| 83 const base::Closure& done_callback) = 0; | 90 const base::Closure& done_callback) = 0; |
| 84 | 91 |
| 85 // Creates a MetricsLogUploader with the specified parameters (see comments on | 92 // Creates a MetricsLogUploader with the specified parameters (see comments on |
| 86 // MetricsLogUploader for details). | 93 // MetricsLogUploader for details). |
| 87 virtual std::unique_ptr<MetricsLogUploader> CreateUploader( | 94 virtual std::unique_ptr<MetricsLogUploader> CreateUploader( |
| 95 const std::string& server_url, |
| 96 const std::string& mime_type, |
| 88 const base::Callback<void(int)>& on_upload_complete) = 0; | 97 const base::Callback<void(int)>& on_upload_complete) = 0; |
| 89 | 98 |
| 90 // Returns the standard interval between upload attempts. | 99 // Returns the standard interval between upload attempts. |
| 91 virtual base::TimeDelta GetStandardUploadInterval() = 0; | 100 virtual base::TimeDelta GetStandardUploadInterval() = 0; |
| 92 | 101 |
| 93 // Returns the name of a key under HKEY_CURRENT_USER that can be used to store | 102 // Returns the name of a key under HKEY_CURRENT_USER that can be used to store |
| 94 // backups of metrics data. Unused except on Windows. | 103 // backups of metrics data. Unused except on Windows. |
| 95 virtual base::string16 GetRegistryBackupKey(); | 104 virtual base::string16 GetRegistryBackupKey(); |
| 96 | 105 |
| 97 // Called on plugin loading errors. | 106 // Called on plugin loading errors. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 109 // shown during first-run. | 118 // shown during first-run. |
| 110 virtual EnableMetricsDefault GetMetricsReportingDefaultState(); | 119 virtual EnableMetricsDefault GetMetricsReportingDefaultState(); |
| 111 | 120 |
| 112 // Returns whether cellular logic is enabled for metrics reporting. | 121 // Returns whether cellular logic is enabled for metrics reporting. |
| 113 virtual bool IsUMACellularUploadLogicEnabled(); | 122 virtual bool IsUMACellularUploadLogicEnabled(); |
| 114 }; | 123 }; |
| 115 | 124 |
| 116 } // namespace metrics | 125 } // namespace metrics |
| 117 | 126 |
| 118 #endif // COMPONENTS_METRICS_METRICS_SERVICE_CLIENT_H_ | 127 #endif // COMPONENTS_METRICS_METRICS_SERVICE_CLIENT_H_ |
| OLD | NEW |