test_metrics_log_uploader.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright 2017 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.
  4. #ifndef COMPONENTS_METRICS_TEST_TEST_METRICS_LOG_UPLOADER_H_
  5. #define COMPONENTS_METRICS_TEST_TEST_METRICS_LOG_UPLOADER_H_
  6. #include "components/metrics/metrics_log_uploader.h"
  7. #include "third_party/metrics_proto/reporting_info.pb.h"
  8. namespace metrics {
  9. class TestMetricsLogUploader : public MetricsLogUploader {
  10. public:
  11. explicit TestMetricsLogUploader(
  12. const MetricsLogUploader::UploadCallback& on_upload_complete);
  13. TestMetricsLogUploader(const TestMetricsLogUploader&) = delete;
  14. TestMetricsLogUploader& operator=(const TestMetricsLogUploader&) = delete;
  15. ~TestMetricsLogUploader() override;
  16. // Mark the current upload complete with the given response code.
  17. void CompleteUpload(int response_code);
  18. // Check if UploadLog has been called.
  19. bool is_uploading() const { return is_uploading_; }
  20. const ReportingInfo& reporting_info() const { return last_reporting_info_; }
  21. private:
  22. // MetricsLogUploader:
  23. void UploadLog(const std::string& compressed_log_data,
  24. const std::string& log_hash,
  25. const std::string& log_signature,
  26. const ReportingInfo& reporting_info) override;
  27. const MetricsLogUploader::UploadCallback on_upload_complete_;
  28. ReportingInfo last_reporting_info_;
  29. bool is_uploading_;
  30. };
  31. } // namespace metrics
  32. #endif // COMPONENTS_METRICS_TEST_TEST_METRICS_LOG_UPLOADER_H_