1 // Copyright 2014 The Chromium Authors
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_LOG_UPLOADER_H_
6 #define COMPONENTS_METRICS_METRICS_LOG_UPLOADER_H_
10 #include "base/callback.h"
11 #include "base/strings/string_piece.h"
17 // MetricsLogUploader is an abstract base class for uploading UMA logs on behalf
19 class MetricsLogUploader {
21 // Type for OnUploadComplete callbacks. These callbacks will receive three
22 // parameters: A response code, a net error code, and a boolean specifying
23 // if the connection was secure (over HTTPS).
24 using UploadCallback = base::RepeatingCallback<void(int, int, bool)>;
26 // Possible service types. This should correspond to a type from
28 enum MetricServiceType {
33 virtual ~MetricsLogUploader() {}
35 // Uploads a log with the specified |compressed_log_data|, a |log_hash| and
36 // |log_signature| for data validation, and |reporting_info|. |log_hash| is
37 // expected to be the hex-encoded SHA1 hash of the log data before compression
38 // and |log_signature| is expected to be a base64-encoded HMAC-SHA256
39 // signature of the log data before compression. When the server receives an
40 // upload it recomputes the hash and signature of the upload and compares it
41 // to the ones inlcuded in the upload. If there is a missmatched, the upload
42 // is flagged. If an Uploader implementation uploads to a server that doesn't
43 // do this validation then |log_hash| and |log_signature| can be ignored.
44 virtual void UploadLog(const std::string& compressed_log_data,
45 const std::string& log_hash,
46 const std::string& log_signature,
47 const ReportingInfo& reporting_info) = 0;
50 } // namespace metrics
52 #endif // COMPONENTS_METRICS_METRICS_LOG_UPLOADER_H_