| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "chrome/browser/ssl/certificate_reporting_test_utils.h" | 5 #include "chrome/browser/ssl/certificate_reporting_test_utils.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 | 82 |
| 83 MockErrorReporter::MockErrorReporter( | 83 MockErrorReporter::MockErrorReporter( |
| 84 net::URLRequestContext* request_context, | 84 net::URLRequestContext* request_context, |
| 85 const GURL& upload_url, | 85 const GURL& upload_url, |
| 86 net::ReportSender::CookiesPreference cookies_preference) | 86 net::ReportSender::CookiesPreference cookies_preference) |
| 87 : certificate_reporting::ErrorReporter(request_context, | 87 : certificate_reporting::ErrorReporter(request_context, |
| 88 upload_url, | 88 upload_url, |
| 89 cookies_preference) {} | 89 cookies_preference) {} |
| 90 | 90 |
| 91 void MockErrorReporter::SendExtendedReportingReport( | 91 void MockErrorReporter::SendExtendedReportingReport( |
| 92 const std::string& serialized_report) { | 92 const std::string& serialized_report, |
| 93 const base::Callback<void()>& success_callback, |
| 94 const base::Callback<void(const GURL&, int)>& error_callback) { |
| 93 certificate_reporting::ErrorReport report; | 95 certificate_reporting::ErrorReport report; |
| 94 ASSERT_TRUE(report.InitializeFromString(serialized_report)); | 96 ASSERT_TRUE(report.InitializeFromString(serialized_report)); |
| 95 latest_hostname_reported_ = report.hostname(); | 97 latest_hostname_reported_ = report.hostname(); |
| 96 } | 98 } |
| 97 | 99 |
| 98 void CertificateReportingTest::SetUpMockReporter() { | 100 void CertificateReportingTest::SetUpMockReporter() { |
| 99 // Set up the mock reporter to track the hostnames that reports get | 101 // Set up the mock reporter to track the hostnames that reports get |
| 100 // sent for. The request_context argument is null here | 102 // sent for. The request_context argument is null here |
| 101 // because the MockErrorReporter doesn't actually use a | 103 // because the MockErrorReporter doesn't actually use a |
| 102 // request_context. (In order to pass a real request_context, the | 104 // request_context. (In order to pass a real request_context, the |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 if (!base::StringToDouble(param, &sendingThreshold)) | 158 if (!base::StringToDouble(param, &sendingThreshold)) |
| 157 return CERT_REPORT_NOT_EXPECTED; | 159 return CERT_REPORT_NOT_EXPECTED; |
| 158 | 160 |
| 159 if (sendingThreshold == 1.0) | 161 if (sendingThreshold == 1.0) |
| 160 return certificate_reporting_test_utils::CERT_REPORT_EXPECTED; | 162 return certificate_reporting_test_utils::CERT_REPORT_EXPECTED; |
| 161 } | 163 } |
| 162 return certificate_reporting_test_utils::CERT_REPORT_NOT_EXPECTED; | 164 return certificate_reporting_test_utils::CERT_REPORT_NOT_EXPECTED; |
| 163 } | 165 } |
| 164 | 166 |
| 165 } // namespace certificate_reporting_test_utils | 167 } // namespace certificate_reporting_test_utils |
| OLD | NEW |