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