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

Side by Side Diff: chrome/browser/ssl/chrome_expect_ct_reporter_unittest.cc

Issue 2648713002: Add response code to the success callback of ReportSender (Closed)
Patch Set: eroman and estark comments Created 3 years, 7 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
OLDNEW
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/ssl/chrome_expect_ct_reporter.h" 5 #include "chrome/browser/ssl/chrome_expect_ct_reporter.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 21 matching lines...) Expand all
32 const char kFailureHistogramName[] = "SSL.ExpectCTReportFailure2"; 32 const char kFailureHistogramName[] = "SSL.ExpectCTReportFailure2";
33 33
34 // A test ReportSender that exposes the latest report URI and 34 // A test ReportSender that exposes the latest report URI and
35 // serialized report to be sent. 35 // serialized report to be sent.
36 class TestCertificateReportSender : public net::ReportSender { 36 class TestCertificateReportSender : public net::ReportSender {
37 public: 37 public:
38 TestCertificateReportSender() 38 TestCertificateReportSender()
39 : ReportSender(nullptr, net::ReportSender::DO_NOT_SEND_COOKIES) {} 39 : ReportSender(nullptr, net::ReportSender::DO_NOT_SEND_COOKIES) {}
40 ~TestCertificateReportSender() override {} 40 ~TestCertificateReportSender() override {}
41 41
42 void Send( 42 void Send(const GURL& report_uri,
43 const GURL& report_uri, 43 base::StringPiece content_type,
44 base::StringPiece content_type, 44 base::StringPiece serialized_report,
45 base::StringPiece serialized_report, 45 const base::Callback<void()>& success_callback,
46 const base::Callback<void()>& success_callback, 46 const base::Callback<void(const GURL&, int, int)>& error_callback)
47 const base::Callback<void(const GURL&, int)>& error_callback) override { 47 override {
48 latest_report_uri_ = report_uri; 48 latest_report_uri_ = report_uri;
49 serialized_report.CopyToString(&latest_serialized_report_); 49 serialized_report.CopyToString(&latest_serialized_report_);
50 content_type.CopyToString(&latest_content_type_); 50 content_type.CopyToString(&latest_content_type_);
51 } 51 }
52 52
53 const GURL& latest_report_uri() const { return latest_report_uri_; } 53 const GURL& latest_report_uri() const { return latest_report_uri_; }
54 54
55 const std::string& latest_content_type() const { 55 const std::string& latest_content_type() const {
56 return latest_content_type_; 56 return latest_content_type_;
57 } 57 }
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 EXPECT_EQ(report_uri, sender->latest_report_uri()); 487 EXPECT_EQ(report_uri, sender->latest_report_uri());
488 EXPECT_FALSE(sender->latest_serialized_report().empty()); 488 EXPECT_FALSE(sender->latest_serialized_report().empty());
489 EXPECT_EQ("application/json; charset=utf-8", sender->latest_content_type()); 489 EXPECT_EQ("application/json; charset=utf-8", sender->latest_content_type());
490 ASSERT_NO_FATAL_FAILURE(CheckExpectCTReport( 490 ASSERT_NO_FATAL_FAILURE(CheckExpectCTReport(
491 sender->latest_serialized_report(), host_port, ssl_info)); 491 sender->latest_serialized_report(), host_port, ssl_info));
492 492
493 histograms.ExpectTotalCount(kFailureHistogramName, 0); 493 histograms.ExpectTotalCount(kFailureHistogramName, 0);
494 histograms.ExpectTotalCount(kSendHistogramName, 1); 494 histograms.ExpectTotalCount(kSendHistogramName, 1);
495 histograms.ExpectBucketCount(kSendHistogramName, true, 1); 495 histograms.ExpectBucketCount(kSendHistogramName, true, 1);
496 } 496 }
OLDNEW
« no previous file with comments | « chrome/browser/ssl/chrome_expect_ct_reporter.cc ('k') | components/certificate_reporting/error_reporter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698