| 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 protocol_negotiation_(PN_UNKNOWN) { |
| 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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 wire_protos.push_back(i->size()); | 227 wire_protos.push_back(i->size()); |
| 226 wire_protos.resize(wire_protos.size() + i->size()); | 228 wire_protos.resize(wire_protos.size() + i->size()); |
| 227 memcpy(&wire_protos[wire_protos.size() - i->size()], | 229 memcpy(&wire_protos[wire_protos.size() - i->size()], |
| 228 i->data(), i->size()); | 230 i->data(), i->size()); |
| 229 } | 231 } |
| 230 DCHECK_EQ(wire_protos.size(), wire_length); | 232 DCHECK_EQ(wire_protos.size(), wire_length); |
| 231 | 233 |
| 232 return wire_protos; | 234 return wire_protos; |
| 233 } | 235 } |
| 234 | 236 |
| 237 void SSLClientSocket::RecordProtocolNegotiation() { |
| 238 if (protocol_negotiation_ == PN_UNKNOWN) |
| 239 return; |
| 240 std::string proto; |
| 241 SSLClientSocket::NextProtoStatus status = GetNextProto(&proto); |
| 242 if (status == kNextProtoUnsupported) |
| 243 return; |
| 244 if (status == kNextProtoNoOverlap) { |
| 245 DCHECK(protocol_negotiation_ != PN_ALPN); |
| 246 protocol_negotiation_ = PN_NPN_NO_OVERLAP; |
| 247 } |
| 248 NextProto protocol_negotiated = SSLClientSocket::NextProtoFromString(proto); |
| 249 UMA_HISTOGRAM_SPARSE_SLOWLY( |
| 250 "Net.SSLProtocolNegotiation", |
| 251 static_cast<base::HistogramBase::Sample>(protocol_negotiation_) + |
| 252 static_cast<base::HistogramBase::Sample>(protocol_negotiated)); |
| 253 } |
| 254 |
| 235 } // namespace net | 255 } // namespace net |
| OLD | NEW |