Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Side by Side Diff: net/url_request/certificate_report_sender_unittest.cc

Issue 1850853004: Use CertificateReportSender error callback to record HPKP UMA metrics (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: eroman comments Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/url_request/certificate_report_sender.cc ('k') | net/url_request/url_request_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 29 matching lines...) Expand all
40 ASSERT_EQ(1u, upload->GetElementReaders()->size()); 40 ASSERT_EQ(1u, upload->GetElementReaders()->size());
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 that sets |called| to
51 // called, it sets |called| to true. 51 // true.
52 void ErrorCallback(bool* called, URLRequest* request) { 52 void ErrorCallback(bool* called, const 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
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
OLDNEW
« no previous file with comments | « net/url_request/certificate_report_sender.cc ('k') | net/url_request/url_request_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698