| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 void RecordUMAOnFailure(const GURL& report_uri, | 109 void RecordUMAOnFailure(const GURL& report_uri, |
| 110 int net_error, | 110 int net_error, |
| 111 int http_response_code) { | 111 int http_response_code) { |
| 112 UMA_HISTOGRAM_SPARSE_SLOWLY("SSL.ExpectCTReportFailure2", -net_error); | 112 UMA_HISTOGRAM_SPARSE_SLOWLY("SSL.ExpectCTReportFailure2", -net_error); |
| 113 } | 113 } |
| 114 | 114 |
| 115 } // namespace | 115 } // namespace |
| 116 | 116 |
| 117 ChromeExpectCTReporter::ChromeExpectCTReporter( | 117 ChromeExpectCTReporter::ChromeExpectCTReporter( |
| 118 net::URLRequestContext* request_context) | 118 net::URLRequestContext* request_context) |
| 119 : report_sender_( | 119 : report_sender_(new net::ReportSender(request_context)) {} |
| 120 new net::ReportSender(request_context, | |
| 121 net::ReportSender::DO_NOT_SEND_COOKIES)) {} | |
| 122 | 120 |
| 123 ChromeExpectCTReporter::~ChromeExpectCTReporter() {} | 121 ChromeExpectCTReporter::~ChromeExpectCTReporter() {} |
| 124 | 122 |
| 125 void ChromeExpectCTReporter::OnExpectCTFailed( | 123 void ChromeExpectCTReporter::OnExpectCTFailed( |
| 126 const net::HostPortPair& host_port_pair, | 124 const net::HostPortPair& host_port_pair, |
| 127 const GURL& report_uri, | 125 const GURL& report_uri, |
| 128 const net::SSLInfo& ssl_info) { | 126 const net::SSLInfo& ssl_info) { |
| 129 if (report_uri.is_empty()) | 127 if (report_uri.is_empty()) |
| 130 return; | 128 return; |
| 131 | 129 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 LOG(ERROR) << "Failed to serialize Expect CT report"; | 172 LOG(ERROR) << "Failed to serialize Expect CT report"; |
| 175 return; | 173 return; |
| 176 } | 174 } |
| 177 | 175 |
| 178 UMA_HISTOGRAM_BOOLEAN("SSL.ExpectCTReportSendingAttempt", true); | 176 UMA_HISTOGRAM_BOOLEAN("SSL.ExpectCTReportSendingAttempt", true); |
| 179 | 177 |
| 180 report_sender_->Send(report_uri, "application/json; charset=utf-8", | 178 report_sender_->Send(report_uri, "application/json; charset=utf-8", |
| 181 serialized_report, base::Callback<void()>(), | 179 serialized_report, base::Callback<void()>(), |
| 182 base::Bind(RecordUMAOnFailure)); | 180 base::Bind(RecordUMAOnFailure)); |
| 183 } | 181 } |
| OLD | NEW |