Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(374)

Side by Side Diff: net/socket/ssl_client_socket.cc

Issue 706203003: Update from https://crrev.com/303153 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/socket/ssl_client_socket.h ('k') | net/socket/ssl_client_socket_nss.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/metrics/sparse_histogram.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "crypto/ec_private_key.h" 10 #include "crypto/ec_private_key.h"
11 #include "net/base/connection_type_histograms.h"
11 #include "net/base/host_port_pair.h" 12 #include "net/base/host_port_pair.h"
12 #include "net/ssl/channel_id_service.h" 13 #include "net/ssl/channel_id_service.h"
13 #include "net/ssl/ssl_config_service.h" 14 #include "net/ssl/ssl_config_service.h"
15 #include "net/ssl/ssl_connection_status_flags.h"
14 16
15 namespace net { 17 namespace net {
16 18
17 SSLClientSocket::SSLClientSocket() 19 SSLClientSocket::SSLClientSocket()
18 : was_npn_negotiated_(false), 20 : was_npn_negotiated_(false),
19 was_spdy_negotiated_(false), 21 was_spdy_negotiated_(false),
20 protocol_negotiated_(kProtoUnknown), 22 protocol_negotiated_(kProtoUnknown),
21 channel_id_sent_(false), 23 channel_id_sent_(false),
22 signed_cert_timestamps_received_(false), 24 signed_cert_timestamps_received_(false),
23 stapled_ocsp_response_received_(false), 25 stapled_ocsp_response_received_(false),
24 negotiation_extension_(kExtensionUnknown) { 26 negotiation_extension_(kExtensionUnknown) {
25 } 27 }
26 28
27 // static 29 // static
28 NextProto SSLClientSocket::NextProtoFromString( 30 NextProto SSLClientSocket::NextProtoFromString(
29 const std::string& proto_string) { 31 const std::string& proto_string) {
30 if (proto_string == "http1.1" || proto_string == "http/1.1") { 32 if (proto_string == "http1.1" || proto_string == "http/1.1") {
31 return kProtoHTTP11; 33 return kProtoHTTP11;
32 } else if (proto_string == "spdy/2") { 34 } else if (proto_string == "spdy/2") {
33 return kProtoDeprecatedSPDY2; 35 return kProtoDeprecatedSPDY2;
34 } else if (proto_string == "spdy/3") { 36 } else if (proto_string == "spdy/3") {
35 return kProtoSPDY3; 37 return kProtoSPDY3;
36 } else if (proto_string == "spdy/3.1") { 38 } else if (proto_string == "spdy/3.1") {
37 return kProtoSPDY31; 39 return kProtoSPDY31;
38 } else if (proto_string == "h2-14") { 40 } else if (proto_string == "h2-15") {
39 // This is the HTTP/2 draft 14 identifier. For internal 41 // This is the HTTP/2 draft-15 identifier. For internal
40 // consistency, HTTP/2 is named SPDY4 within Chromium. 42 // consistency, HTTP/2 is named SPDY4 within Chromium.
41 return kProtoSPDY4; 43 return kProtoSPDY4;
42 } else if (proto_string == "quic/1+spdy/3") { 44 } else if (proto_string == "quic/1+spdy/3") {
43 return kProtoQUIC1SPDY3; 45 return kProtoQUIC1SPDY3;
44 } else { 46 } else {
45 return kProtoUnknown; 47 return kProtoUnknown;
46 } 48 }
47 } 49 }
48 50
49 // static 51 // static
50 const char* SSLClientSocket::NextProtoToString(NextProto next_proto) { 52 const char* SSLClientSocket::NextProtoToString(NextProto next_proto) {
51 switch (next_proto) { 53 switch (next_proto) {
52 case kProtoHTTP11: 54 case kProtoHTTP11:
53 return "http/1.1"; 55 return "http/1.1";
54 case kProtoDeprecatedSPDY2: 56 case kProtoDeprecatedSPDY2:
55 return "spdy/2"; 57 return "spdy/2";
56 case kProtoSPDY3: 58 case kProtoSPDY3:
57 return "spdy/3"; 59 return "spdy/3";
58 case kProtoSPDY31: 60 case kProtoSPDY31:
59 return "spdy/3.1"; 61 return "spdy/3.1";
60 case kProtoSPDY4: 62 case kProtoSPDY4:
61 // This is the HTTP/2 draft 14 identifier. For internal 63 // This is the HTTP/2 draft-15 identifier. For internal
62 // consistency, HTTP/2 is named SPDY4 within Chromium. 64 // consistency, HTTP/2 is named SPDY4 within Chromium.
63 return "h2-14"; 65 return "h2-15";
64 case kProtoQUIC1SPDY3: 66 case kProtoQUIC1SPDY3:
65 return "quic/1+spdy/3"; 67 return "quic/1+spdy/3";
66 case kProtoUnknown: 68 case kProtoUnknown:
67 break; 69 break;
68 } 70 }
69 return "unknown"; 71 return "unknown";
70 } 72 }
71 73
72 // static 74 // static
73 const char* SSLClientSocket::NextProtoStatusToString( 75 const char* SSLClientSocket::NextProtoStatusToString(
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 else if (!channel_id_service->IsSystemTimeValid()) 177 else if (!channel_id_service->IsSystemTimeValid())
176 supported = CLIENT_BAD_SYSTEM_TIME; 178 supported = CLIENT_BAD_SYSTEM_TIME;
177 else 179 else
178 supported = CLIENT_ONLY; 180 supported = CLIENT_ONLY;
179 } 181 }
180 UMA_HISTOGRAM_ENUMERATION("DomainBoundCerts.Support", supported, 182 UMA_HISTOGRAM_ENUMERATION("DomainBoundCerts.Support", supported,
181 CHANNEL_ID_USAGE_MAX); 183 CHANNEL_ID_USAGE_MAX);
182 } 184 }
183 185
184 // static 186 // static
187 void SSLClientSocket::RecordConnectionTypeMetrics(int ssl_version) {
188 UpdateConnectionTypeHistograms(CONNECTION_SSL);
189 switch (ssl_version) {
190 case SSL_CONNECTION_VERSION_SSL2:
191 UpdateConnectionTypeHistograms(CONNECTION_SSL_SSL2);
192 break;
193 case SSL_CONNECTION_VERSION_SSL3:
194 UpdateConnectionTypeHistograms(CONNECTION_SSL_SSL3);
195 break;
196 case SSL_CONNECTION_VERSION_TLS1:
197 UpdateConnectionTypeHistograms(CONNECTION_SSL_TLS1);
198 break;
199 case SSL_CONNECTION_VERSION_TLS1_1:
200 UpdateConnectionTypeHistograms(CONNECTION_SSL_TLS1_1);
201 break;
202 case SSL_CONNECTION_VERSION_TLS1_2:
203 UpdateConnectionTypeHistograms(CONNECTION_SSL_TLS1_2);
204 break;
205 }
206 }
207
208 // static
185 bool SSLClientSocket::IsChannelIDEnabled( 209 bool SSLClientSocket::IsChannelIDEnabled(
186 const SSLConfig& ssl_config, 210 const SSLConfig& ssl_config,
187 ChannelIDService* channel_id_service) { 211 ChannelIDService* channel_id_service) {
188 if (!ssl_config.channel_id_enabled) 212 if (!ssl_config.channel_id_enabled)
189 return false; 213 return false;
190 if (!channel_id_service) { 214 if (!channel_id_service) {
191 DVLOG(1) << "NULL channel_id_service_, not enabling channel ID."; 215 DVLOG(1) << "NULL channel_id_service_, not enabling channel ID.";
192 return false; 216 return false;
193 } 217 }
194 if (!crypto::ECPrivateKey::IsSupported()) { 218 if (!crypto::ECPrivateKey::IsSupported()) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 } else { 283 } else {
260 sample += 500; 284 sample += 500;
261 } 285 }
262 } else { 286 } else {
263 DCHECK_EQ(kExtensionALPN, negotiation_extension_); 287 DCHECK_EQ(kExtensionALPN, negotiation_extension_);
264 } 288 }
265 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.SSLProtocolNegotiation", sample); 289 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.SSLProtocolNegotiation", sample);
266 } 290 }
267 291
268 } // namespace net 292 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/ssl_client_socket.h ('k') | net/socket/ssl_client_socket_nss.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698