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/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 | 13 |
14 namespace metrics { | 14 namespace metrics { |
15 | 15 |
16 // MetricsLogUploader is an abstract base class for uploading UMA logs on behalf | 16 // MetricsLogUploader is an abstract base class for uploading UMA logs on behalf |
17 // of MetricsService. | 17 // of MetricsService. |
18 class MetricsLogUploader { | 18 class MetricsLogUploader { |
19 public: | 19 public: |
20 // Constructs the uploader that will upload logs to the specified |server_url| | 20 // Constructs the uploader that will upload logs to the specified |server_url| |
21 // with the given |mime_type|. The |on_upload_complete| callback will be | 21 // with the given |mime_type|. The |on_upload_complete| callback will be |
22 // called with the HTTP response code of the upload or with -1 on an error. | 22 // called with the HTTP response code of the upload or with -1 on an error. |
23 MetricsLogUploader(const std::string& server_url, | 23 MetricsLogUploader(const std::string& server_url, |
24 const std::string& mime_type, | 24 const std::string& mime_type, |
25 const base::Callback<void(int)>& on_upload_complete); | 25 const base::Callback<void(int)>& on_upload_complete); |
26 virtual ~MetricsLogUploader(); | 26 virtual ~MetricsLogUploader(); |
27 | 27 |
28 // Uploads a log with the specified |log_data| and |log_hash|. |log_hash| is | 28 // Uploads a log with the specified |compressed_log_data| and |log_hash|. |
29 // expected to be the hex-encoded SHA1 hash of |log_data|. | 29 // |log_hash| is expected to be the hex-encoded SHA1 hash of the log data |
30 virtual bool UploadLog(const std::string& log_data, | 30 // before compression. |
| 31 virtual bool UploadLog(const std::string& compressed_log_data, |
31 const std::string& log_hash) = 0; | 32 const std::string& log_hash) = 0; |
32 | 33 |
33 protected: | 34 protected: |
34 const std::string server_url_; | 35 const std::string server_url_; |
35 const std::string mime_type_; | 36 const std::string mime_type_; |
36 const base::Callback<void(int)> on_upload_complete_; | 37 const base::Callback<void(int)> on_upload_complete_; |
37 | 38 |
38 private: | 39 private: |
39 DISALLOW_COPY_AND_ASSIGN(MetricsLogUploader); | 40 DISALLOW_COPY_AND_ASSIGN(MetricsLogUploader); |
40 }; | 41 }; |
41 | 42 |
42 } // namespace metrics | 43 } // namespace metrics |
43 | 44 |
44 #endif // COMPONENTS_METRICS_METRICS_LOG_UPLOADER_H_ | 45 #endif // COMPONENTS_METRICS_METRICS_LOG_UPLOADER_H_ |
OLD | NEW |