xref: /aosp_15_r20/external/cronet/components/metrics/test/test_metrics_log_uploader.cc (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
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 #include "components/metrics/test/test_metrics_log_uploader.h"
6 #include "components/metrics/metrics_log_uploader.h"
7 
8 namespace metrics {
9 
TestMetricsLogUploader(const MetricsLogUploader::UploadCallback & on_upload_complete)10 TestMetricsLogUploader::TestMetricsLogUploader(
11     const MetricsLogUploader::UploadCallback& on_upload_complete)
12     : on_upload_complete_(on_upload_complete), is_uploading_(false) {}
13 
14 TestMetricsLogUploader::~TestMetricsLogUploader() = default;
15 
CompleteUpload(int response_code,bool force_discard)16 void TestMetricsLogUploader::CompleteUpload(int response_code,
17                                             bool force_discard) {
18   DCHECK(is_uploading_);
19   is_uploading_ = false;
20   last_reporting_info_.Clear();
21   on_upload_complete_.Run(response_code, /*error_code=*/0, /*was_https=*/false,
22                           force_discard, /*force_discard_reason=*/"");
23 }
24 
UploadLog(const std::string & compressed_log_data,const LogMetadata & log_metadata,const std::string & log_hash,const std::string & log_signature,const ReportingInfo & reporting_info)25 void TestMetricsLogUploader::UploadLog(const std::string& compressed_log_data,
26                                        const LogMetadata& log_metadata,
27                                        const std::string& log_hash,
28                                        const std::string& log_signature,
29                                        const ReportingInfo& reporting_info) {
30   DCHECK(!is_uploading_);
31   is_uploading_ = true;
32   last_reporting_info_ = reporting_info;
33 }
34 
35 }  // namespace metrics
36