OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/safe_browsing/certificate_reporting_service.h" | 5 #include "chrome/browser/safe_browsing/certificate_reporting_service.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/atomic_sequence_num.h" | 9 #include "base/atomic_sequence_num.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 SetExpectedFailedReportCountOnTearDown(6); | 198 SetExpectedFailedReportCountOnTearDown(6); |
199 | 199 |
200 std::unique_ptr<base::SimpleTestClock> clock(new base::SimpleTestClock()); | 200 std::unique_ptr<base::SimpleTestClock> clock(new base::SimpleTestClock()); |
201 const base::Time reference_time = base::Time::Now(); | 201 const base::Time reference_time = base::Time::Now(); |
202 clock->SetNow(reference_time); | 202 clock->SetNow(reference_time); |
203 | 203 |
204 const GURL kFailureURL = | 204 const GURL kFailureURL = |
205 net::URLRequestFailedJob::GetMockHttpsUrl(net::ERR_SSL_PROTOCOL_ERROR); | 205 net::URLRequestFailedJob::GetMockHttpsUrl(net::ERR_SSL_PROTOCOL_ERROR); |
206 certificate_reporting::ErrorReporter* certificate_error_reporter = | 206 certificate_reporting::ErrorReporter* certificate_error_reporter = |
207 new certificate_reporting::ErrorReporter( | 207 new certificate_reporting::ErrorReporter( |
208 url_request_context_getter()->GetURLRequestContext(), kFailureURL, | 208 url_request_context_getter()->GetURLRequestContext(), kFailureURL); |
209 net::ReportSender::DO_NOT_SEND_COOKIES); | |
210 | 209 |
211 CertificateReportingService::BoundedReportList* list = | 210 CertificateReportingService::BoundedReportList* list = |
212 new CertificateReportingService::BoundedReportList(2); | 211 new CertificateReportingService::BoundedReportList(2); |
213 | 212 |
214 // Create a reporter with retries enabled. | 213 // Create a reporter with retries enabled. |
215 CertificateReportingService::Reporter reporter( | 214 CertificateReportingService::Reporter reporter( |
216 std::unique_ptr<certificate_reporting::ErrorReporter>( | 215 std::unique_ptr<certificate_reporting::ErrorReporter>( |
217 certificate_error_reporter), | 216 certificate_error_reporter), |
218 std::unique_ptr<CertificateReportingService::BoundedReportList>(list), | 217 std::unique_ptr<CertificateReportingService::BoundedReportList>(list), |
219 clock.get(), base::TimeDelta::FromSeconds(100), | 218 clock.get(), base::TimeDelta::FromSeconds(100), |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 SetExpectedFailedReportCountOnTearDown(2); | 288 SetExpectedFailedReportCountOnTearDown(2); |
290 | 289 |
291 std::unique_ptr<base::SimpleTestClock> clock(new base::SimpleTestClock()); | 290 std::unique_ptr<base::SimpleTestClock> clock(new base::SimpleTestClock()); |
292 base::Time reference_time = base::Time::Now(); | 291 base::Time reference_time = base::Time::Now(); |
293 clock->SetNow(reference_time); | 292 clock->SetNow(reference_time); |
294 | 293 |
295 const GURL kFailureURL = | 294 const GURL kFailureURL = |
296 net::URLRequestFailedJob::GetMockHttpsUrl(net::ERR_SSL_PROTOCOL_ERROR); | 295 net::URLRequestFailedJob::GetMockHttpsUrl(net::ERR_SSL_PROTOCOL_ERROR); |
297 certificate_reporting::ErrorReporter* certificate_error_reporter = | 296 certificate_reporting::ErrorReporter* certificate_error_reporter = |
298 new certificate_reporting::ErrorReporter( | 297 new certificate_reporting::ErrorReporter( |
299 url_request_context_getter()->GetURLRequestContext(), kFailureURL, | 298 url_request_context_getter()->GetURLRequestContext(), kFailureURL); |
300 net::ReportSender::DO_NOT_SEND_COOKIES); | |
301 | 299 |
302 CertificateReportingService::BoundedReportList* list = | 300 CertificateReportingService::BoundedReportList* list = |
303 new CertificateReportingService::BoundedReportList(2); | 301 new CertificateReportingService::BoundedReportList(2); |
304 | 302 |
305 // Create a reporter with retries disabled. | 303 // Create a reporter with retries disabled. |
306 CertificateReportingService::Reporter reporter( | 304 CertificateReportingService::Reporter reporter( |
307 std::unique_ptr<certificate_reporting::ErrorReporter>( | 305 std::unique_ptr<certificate_reporting::ErrorReporter>( |
308 certificate_error_reporter), | 306 certificate_error_reporter), |
309 std::unique_ptr<CertificateReportingService::BoundedReportList>(list), | 307 std::unique_ptr<CertificateReportingService::BoundedReportList>(list), |
310 clock.get(), base::TimeDelta::FromSeconds(100), | 308 clock.get(), base::TimeDelta::FromSeconds(100), |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 // callbacks should be called. The report id is again 0 since the pending | 701 // callbacks should be called. The report id is again 0 since the pending |
704 // report queue has been cleared above. | 702 // report queue has been cleared above. |
705 service()->Send(MakeReport("report1")); | 703 service()->Send(MakeReport("report1")); |
706 | 704 |
707 // Resume delayed report. Two reports are successfully sent. | 705 // Resume delayed report. Two reports are successfully sent. |
708 test_helper()->ResumeDelayedRequest(); | 706 test_helper()->ResumeDelayedRequest(); |
709 test_helper()->WaitForRequestsDestroyed( | 707 test_helper()->WaitForRequestsDestroyed( |
710 ReportExpectation::Delayed({{"report0", RetryStatus::NOT_RETRIED}, | 708 ReportExpectation::Delayed({{"report0", RetryStatus::NOT_RETRIED}, |
711 {"report1", RetryStatus::NOT_RETRIED}})); | 709 {"report1", RetryStatus::NOT_RETRIED}})); |
712 } | 710 } |
OLD | NEW |