Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/socket/ssl_client_socket.h" | 5 #include "net/socket/ssl_client_socket.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "base/metrics/sparse_histogram.h" | |
| 8 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 9 #include "crypto/ec_private_key.h" | 10 #include "crypto/ec_private_key.h" |
| 10 #include "net/base/host_port_pair.h" | 11 #include "net/base/host_port_pair.h" |
| 11 #include "net/ssl/channel_id_service.h" | 12 #include "net/ssl/channel_id_service.h" |
| 12 #include "net/ssl/ssl_config_service.h" | 13 #include "net/ssl/ssl_config_service.h" |
| 13 | 14 |
| 14 namespace net { | 15 namespace net { |
| 15 | 16 |
| 16 SSLClientSocket::SSLClientSocket() | 17 SSLClientSocket::SSLClientSocket() |
| 17 : was_npn_negotiated_(false), | 18 : was_npn_negotiated_(false), |
| 18 was_spdy_negotiated_(false), | 19 was_spdy_negotiated_(false), |
| 19 protocol_negotiated_(kProtoUnknown), | 20 protocol_negotiated_(kProtoUnknown), |
| 20 channel_id_sent_(false), | 21 channel_id_sent_(false), |
| 21 signed_cert_timestamps_received_(false), | 22 signed_cert_timestamps_received_(false), |
| 22 stapled_ocsp_response_received_(false) { | 23 stapled_ocsp_response_received_(false), |
| 24 negotiation_extension_(kExtensionUnknown) { | |
| 23 } | 25 } |
| 24 | 26 |
| 25 // static | 27 // static |
| 26 NextProto SSLClientSocket::NextProtoFromString( | 28 NextProto SSLClientSocket::NextProtoFromString( |
| 27 const std::string& proto_string) { | 29 const std::string& proto_string) { |
| 28 if (proto_string == "http1.1" || proto_string == "http/1.1") { | 30 if (proto_string == "http1.1" || proto_string == "http/1.1") { |
| 29 return kProtoHTTP11; | 31 return kProtoHTTP11; |
| 30 } else if (proto_string == "spdy/2") { | 32 } else if (proto_string == "spdy/2") { |
| 31 return kProtoDeprecatedSPDY2; | 33 return kProtoDeprecatedSPDY2; |
| 32 } else if (proto_string == "spdy/3") { | 34 } else if (proto_string == "spdy/3") { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 } | 119 } |
| 118 | 120 |
| 119 bool SSLClientSocket::set_was_spdy_negotiated(bool negotiated) { | 121 bool SSLClientSocket::set_was_spdy_negotiated(bool negotiated) { |
| 120 return was_spdy_negotiated_ = negotiated; | 122 return was_spdy_negotiated_ = negotiated; |
| 121 } | 123 } |
| 122 | 124 |
| 123 void SSLClientSocket::set_protocol_negotiated(NextProto protocol_negotiated) { | 125 void SSLClientSocket::set_protocol_negotiated(NextProto protocol_negotiated) { |
| 124 protocol_negotiated_ = protocol_negotiated; | 126 protocol_negotiated_ = protocol_negotiated; |
| 125 } | 127 } |
| 126 | 128 |
| 129 void SSLClientSocket::set_negotiation_extension( | |
| 130 SSLNegotiationExtension negotiation_extension) { | |
| 131 negotiation_extension_ = negotiation_extension; | |
| 132 } | |
| 133 | |
| 127 bool SSLClientSocket::WasChannelIDSent() const { | 134 bool SSLClientSocket::WasChannelIDSent() const { |
| 128 return channel_id_sent_; | 135 return channel_id_sent_; |
| 129 } | 136 } |
| 130 | 137 |
| 131 void SSLClientSocket::set_channel_id_sent(bool channel_id_sent) { | 138 void SSLClientSocket::set_channel_id_sent(bool channel_id_sent) { |
| 132 channel_id_sent_ = channel_id_sent; | 139 channel_id_sent_ = channel_id_sent; |
| 133 } | 140 } |
| 134 | 141 |
| 135 void SSLClientSocket::set_signed_cert_timestamps_received( | 142 void SSLClientSocket::set_signed_cert_timestamps_received( |
| 136 bool signed_cert_timestamps_received) { | 143 bool signed_cert_timestamps_received) { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 225 wire_protos.push_back(i->size()); | 232 wire_protos.push_back(i->size()); |
| 226 wire_protos.resize(wire_protos.size() + i->size()); | 233 wire_protos.resize(wire_protos.size() + i->size()); |
| 227 memcpy(&wire_protos[wire_protos.size() - i->size()], | 234 memcpy(&wire_protos[wire_protos.size() - i->size()], |
| 228 i->data(), i->size()); | 235 i->data(), i->size()); |
| 229 } | 236 } |
| 230 DCHECK_EQ(wire_protos.size(), wire_length); | 237 DCHECK_EQ(wire_protos.size(), wire_length); |
| 231 | 238 |
| 232 return wire_protos; | 239 return wire_protos; |
| 233 } | 240 } |
| 234 | 241 |
| 242 void SSLClientSocket::RecordNegotiationExtension() { | |
| 243 if (negotiation_extension_ == kExtensionUnknown) | |
| 244 return; | |
| 245 std::string proto; | |
| 246 SSLClientSocket::NextProtoStatus status = GetNextProto(&proto); | |
| 247 if (status == kNextProtoUnsupported) | |
| 248 return; | |
| 249 // Convert protocol into numerical value for histogram. | |
| 250 NextProto protocol_negotiated = SSLClientSocket::NextProtoFromString(proto); | |
| 251 base::HistogramBase::Sample sample = | |
| 252 static_cast<base::HistogramBase::Sample>(protocol_negotiated); | |
| 253 // In addition to the protocol negotiated, we want to record which TLS | |
| 254 // extension was used, and in case of NPN, whether there was overlap between | |
| 255 // server and client list of supported protocols. | |
| 256 if (negotiation_extension_ == kExtensionNPN) { | |
| 257 if (status == kNextProtoNoOverlap) { | |
| 258 sample += 1000; | |
| 259 } else { | |
| 260 sample += 500; | |
|
davidben
2014/10/03 17:55:07
This is probably worth a comment in net/socket/nex
Bence
2014/10/10 15:26:10
Done.
| |
| 261 } | |
| 262 } | |
|
davidben
2014/10/03 17:55:07
Nit: I'd put in an
} else {
DCHECK_EQ(kExten
Bence
2014/10/10 15:26:10
Done.
| |
| 263 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.SSLProtocolNegotiation", sample); | |
| 264 } | |
| 265 | |
| 235 } // namespace net | 266 } // namespace net |
| OLD | NEW |