Chromium Code Reviews| 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 "net/url_request/certificate_report_sender.h" | 5 #include "net/url_request/certificate_report_sender.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 41 | 41 |
| 42 const UploadBytesElementReader* reader = | 42 const UploadBytesElementReader* reader = |
| 43 (*upload->GetElementReaders())[0]->AsBytesReader(); | 43 (*upload->GetElementReaders())[0]->AsBytesReader(); |
| 44 ASSERT_TRUE(reader); | 44 ASSERT_TRUE(reader); |
| 45 std::string upload_data(reader->bytes(), reader->length()); | 45 std::string upload_data(reader->bytes(), reader->length()); |
| 46 | 46 |
| 47 EXPECT_EQ(1u, expect_reports->erase(upload_data)); | 47 EXPECT_EQ(1u, expect_reports->erase(upload_data)); |
| 48 } | 48 } |
| 49 | 49 |
| 50 // Provides an error callback for report sending. If the callback is | 50 // Provides an error callback for report sending. If the callback is |
| 51 // called, it sets |called| to true. | 51 // called, it sets |called| to true. |
|
eroman
2016/04/02 01:55:25
Maybe rephrase this comment to just saying it sets
estark
2016/04/05 00:57:30
Done.
| |
| 52 void ErrorCallback(bool* called, URLRequest* request) { | 52 void ErrorCallback(bool* called, GURL report_uri, int net_error) { |
| 53 EXPECT_FALSE(request->status().is_success()); | 53 EXPECT_NE(OK, net_error); |
| 54 *called = true; | 54 *called = true; |
| 55 } | 55 } |
| 56 | 56 |
| 57 // A network delegate that lets tests check that a certificate report | 57 // A network delegate that lets tests check that a certificate report |
| 58 // was sent. It counts the number of requests and lets tests register a | 58 // was sent. It counts the number of requests and lets tests register a |
| 59 // callback to run when the request is destroyed. It also checks that | 59 // callback to run when the request is destroyed. It also checks that |
| 60 // the uploaded data is as expected. | 60 // the uploaded data is as expected. |
| 61 class TestCertificateReportSenderNetworkDelegate : public NetworkDelegateImpl { | 61 class TestCertificateReportSenderNetworkDelegate : public NetworkDelegateImpl { |
| 62 public: | 62 public: |
| 63 TestCertificateReportSenderNetworkDelegate() | 63 TestCertificateReportSenderNetworkDelegate() |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 286 GURL url = URLRequestMockDataJob::GetMockHttpsUrl("dummy data", 1); | 286 GURL url = URLRequestMockDataJob::GetMockHttpsUrl("dummy data", 1); |
| 287 CertificateReportSender reporter( | 287 CertificateReportSender reporter( |
| 288 context(), CertificateReportSender::DO_NOT_SEND_COOKIES); | 288 context(), CertificateReportSender::DO_NOT_SEND_COOKIES); |
| 289 | 289 |
| 290 network_delegate_.set_expect_cookies(false); | 290 network_delegate_.set_expect_cookies(false); |
| 291 SendReport(&reporter, kDummyReport, url, 0); | 291 SendReport(&reporter, kDummyReport, url, 0); |
| 292 } | 292 } |
| 293 | 293 |
| 294 } // namespace | 294 } // namespace |
| 295 } // namespace net | 295 } // namespace net |
| OLD | NEW |