Chromium Code Reviews| 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_LOG_UPLOADER_H_ | 5 #ifndef COMPONENTS_METRICS_METRICS_LOG_UPLOADER_H_ |
| 6 #define COMPONENTS_METRICS_METRICS_LOG_UPLOADER_H_ | 6 #define COMPONENTS_METRICS_METRICS_LOG_UPLOADER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 | 12 |
| 13 namespace metrics { | 13 namespace metrics { |
| 14 | 14 |
| 15 // MetricsLogUploader is an abstract base class for uploading UMA logs on behalf | 15 // MetricsLogUploader is an abstract base class for uploading UMA logs on behalf |
| 16 // of MetricsService. | 16 // of MetricsService. |
| 17 class MetricsLogUploader { | 17 class MetricsLogUploader { |
| 18 public: | 18 public: |
| 19 // Possible service types. This should correspond to a type from | |
| 20 // DataUseUserData. | |
| 21 enum MetricServiceType { | |
| 22 UMA, | |
| 23 UKM, | |
| 24 }; | |
| 25 | |
| 19 // Constructs the uploader that will upload logs to the specified |server_url| | 26 // Constructs the uploader that will upload logs to the specified |server_url| |
| 20 // with the given |mime_type|. The |on_upload_complete| callback will be | 27 // with the given |mime_type|. The |service_type| marks which service the |
| 21 // called with the HTTP response code of the upload or with -1 on an error. | 28 // data usage should be attributed to. The |on_upload_complete| callback will |
| 29 // be called with the HTTP response code of the upload or with -1 on an error. | |
| 22 MetricsLogUploader(const std::string& server_url, | 30 MetricsLogUploader(const std::string& server_url, |
| 23 const std::string& mime_type, | 31 const std::string& mime_type, |
| 32 MetricServiceType service_type, | |
| 24 const base::Callback<void(int)>& on_upload_complete); | 33 const base::Callback<void(int)>& on_upload_complete); |
| 25 virtual ~MetricsLogUploader(); | 34 virtual ~MetricsLogUploader(); |
| 26 | 35 |
| 27 // Uploads a log with the specified |compressed_log_data| and |log_hash|. | 36 // Uploads a log with the specified |compressed_log_data| and |log_hash|. |
| 28 // |log_hash| is expected to be the hex-encoded SHA1 hash of the log data | 37 // |log_hash| is expected to be the hex-encoded SHA1 hash of the log data |
| 29 // before compression. | 38 // before compression. |
| 30 virtual void UploadLog(const std::string& compressed_log_data, | 39 virtual void UploadLog(const std::string& compressed_log_data, |
| 31 const std::string& log_hash) = 0; | 40 const std::string& log_hash) = 0; |
| 32 | 41 |
| 33 protected: | 42 protected: |
| 34 const std::string server_url_; | 43 const std::string server_url_; |
| 35 const std::string mime_type_; | 44 const std::string mime_type_; |
| 45 | |
| 46 // Which service type this uploads for. This is used for bandwidth | |
| 47 // attribution. | |
| 48 MetricServiceType service_type_; | |
|
Alexei Svitkine (slow)
2017/02/22 15:46:10
Nit: const?
rkaplow
2017/02/22 16:11:35
Done.
| |
| 49 | |
| 36 const base::Callback<void(int)> on_upload_complete_; | 50 const base::Callback<void(int)> on_upload_complete_; |
| 37 | 51 |
| 38 private: | 52 private: |
| 39 DISALLOW_COPY_AND_ASSIGN(MetricsLogUploader); | 53 DISALLOW_COPY_AND_ASSIGN(MetricsLogUploader); |
| 40 }; | 54 }; |
| 41 | 55 |
| 42 } // namespace metrics | 56 } // namespace metrics |
| 43 | 57 |
| 44 #endif // COMPONENTS_METRICS_METRICS_LOG_UPLOADER_H_ | 58 #endif // COMPONENTS_METRICS_METRICS_LOG_UPLOADER_H_ |
| OLD | NEW |