| 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/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 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 const char kSendHistogramName[] = "SSL.ExpectCTReportSendingAttempt"; | 31 const char kSendHistogramName[] = "SSL.ExpectCTReportSendingAttempt"; |
| 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() : ReportSender(nullptr) {} |
| 39 : ReportSender(nullptr, net::ReportSender::DO_NOT_SEND_COOKIES) {} | |
| 40 ~TestCertificateReportSender() override {} | 39 ~TestCertificateReportSender() override {} |
| 41 | 40 |
| 42 void Send( | 41 void Send( |
| 43 const GURL& report_uri, | 42 const GURL& report_uri, |
| 44 base::StringPiece content_type, | 43 base::StringPiece content_type, |
| 45 base::StringPiece serialized_report, | 44 base::StringPiece serialized_report, |
| 46 const base::Callback<void()>& success_callback, | 45 const base::Callback<void()>& success_callback, |
| 47 const base::Callback<void(const GURL&, int)>& error_callback) override { | 46 const base::Callback<void(const GURL&, int)>& error_callback) override { |
| 48 latest_report_uri_ = report_uri; | 47 latest_report_uri_ = report_uri; |
| 49 serialized_report.CopyToString(&latest_serialized_report_); | 48 serialized_report.CopyToString(&latest_serialized_report_); |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 EXPECT_EQ(report_uri, sender->latest_report_uri()); | 486 EXPECT_EQ(report_uri, sender->latest_report_uri()); |
| 488 EXPECT_FALSE(sender->latest_serialized_report().empty()); | 487 EXPECT_FALSE(sender->latest_serialized_report().empty()); |
| 489 EXPECT_EQ("application/json; charset=utf-8", sender->latest_content_type()); | 488 EXPECT_EQ("application/json; charset=utf-8", sender->latest_content_type()); |
| 490 ASSERT_NO_FATAL_FAILURE(CheckExpectCTReport( | 489 ASSERT_NO_FATAL_FAILURE(CheckExpectCTReport( |
| 491 sender->latest_serialized_report(), host_port, ssl_info)); | 490 sender->latest_serialized_report(), host_port, ssl_info)); |
| 492 | 491 |
| 493 histograms.ExpectTotalCount(kFailureHistogramName, 0); | 492 histograms.ExpectTotalCount(kFailureHistogramName, 0); |
| 494 histograms.ExpectTotalCount(kSendHistogramName, 1); | 493 histograms.ExpectTotalCount(kSendHistogramName, 1); |
| 495 histograms.ExpectBucketCount(kSendHistogramName, true, 1); | 494 histograms.ExpectBucketCount(kSendHistogramName, true, 1); |
| 496 } | 495 } |
| OLD | NEW |