• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2017 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.
4 
5 #ifndef COMPONENTS_METRICS_TEST_TEST_METRICS_LOG_UPLOADER_H_
6 #define COMPONENTS_METRICS_TEST_TEST_METRICS_LOG_UPLOADER_H_
7 
8 #include "base/memory/weak_ptr.h"
9 #include "components/metrics/metrics_log_uploader.h"
10 #include "third_party/metrics_proto/reporting_info.pb.h"
11 
12 namespace metrics {
13 
14 class TestMetricsLogUploader
15     : public MetricsLogUploader,
16       public base::SupportsWeakPtr<TestMetricsLogUploader> {
17  public:
18   explicit TestMetricsLogUploader(
19       const MetricsLogUploader::UploadCallback& on_upload_complete);
20 
21   TestMetricsLogUploader(const TestMetricsLogUploader&) = delete;
22   TestMetricsLogUploader& operator=(const TestMetricsLogUploader&) = delete;
23 
24   ~TestMetricsLogUploader() override;
25 
26   // Mark the current upload complete with the given response code.
27   void CompleteUpload(int response_code, bool force_discard = false);
28 
29   // Check if UploadLog has been called.
is_uploading()30   bool is_uploading() const { return is_uploading_; }
31 
reporting_info()32   const ReportingInfo& reporting_info() const { return last_reporting_info_; }
33 
34  private:
35   // MetricsLogUploader:
36   void UploadLog(const std::string& compressed_log_data,
37                  const std::string& log_hash,
38                  const std::string& log_signature,
39                  const ReportingInfo& reporting_info) override;
40 
41   const MetricsLogUploader::UploadCallback on_upload_complete_;
42   ReportingInfo last_reporting_info_;
43   bool is_uploading_;
44 };
45 
46 }  // namespace metrics
47 
48 #endif  // COMPONENTS_METRICS_TEST_TEST_METRICS_LOG_UPLOADER_H_
49