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

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

Issue 2243453002: Replace SSLProtocolNegotiation histogram with SSLNegotiatedAlpnProtocol. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 4 months 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
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_impl.h" 5 #include "net/socket/ssl_client_socket_impl.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <openssl/bio.h> 8 #include <openssl/bio.h>
9 #include <openssl/bytestring.h> 9 #include <openssl/bytestring.h>
10 #include <openssl/err.h> 10 #include <openssl/err.h>
(...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after
1215 SSL_get0_alpn_selected(ssl_, &alpn_proto, &alpn_len); 1215 SSL_get0_alpn_selected(ssl_, &alpn_proto, &alpn_len);
1216 if (alpn_len > 0) { 1216 if (alpn_len > 0) {
1217 base::StringPiece proto(reinterpret_cast<const char*>(alpn_proto), 1217 base::StringPiece proto(reinterpret_cast<const char*>(alpn_proto),
1218 alpn_len); 1218 alpn_len);
1219 negotiated_protocol_ = NextProtoFromString(proto); 1219 negotiated_protocol_ = NextProtoFromString(proto);
1220 npn_status_ = kNextProtoNegotiated; 1220 npn_status_ = kNextProtoNegotiated;
1221 negotiation_extension_ = kExtensionALPN; 1221 negotiation_extension_ = kExtensionALPN;
1222 } 1222 }
1223 } 1223 }
1224 1224
1225 RecordNegotiationExtension(); 1225 RecordNegotiatedProtocol();
1226 RecordChannelIDSupport(); 1226 RecordChannelIDSupport();
1227 1227
1228 const uint8_t* ocsp_response_raw; 1228 const uint8_t* ocsp_response_raw;
1229 size_t ocsp_response_len; 1229 size_t ocsp_response_len;
1230 SSL_get0_ocsp_response(ssl_, &ocsp_response_raw, &ocsp_response_len); 1230 SSL_get0_ocsp_response(ssl_, &ocsp_response_raw, &ocsp_response_len);
1231 std::string ocsp_response; 1231 std::string ocsp_response;
1232 if (ocsp_response_len > 0) { 1232 if (ocsp_response_len > 0) {
1233 ocsp_response_.assign(reinterpret_cast<const char*>(ocsp_response_raw), 1233 ocsp_response_.assign(reinterpret_cast<const char*>(ocsp_response_raw),
1234 ocsp_response_len); 1234 ocsp_response_len);
1235 } 1235 }
(...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after
2335 void SSLClientSocketImpl::LogConnectEndEvent(int rv) { 2335 void SSLClientSocketImpl::LogConnectEndEvent(int rv) {
2336 if (rv != OK) { 2336 if (rv != OK) {
2337 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SSL_CONNECT, rv); 2337 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SSL_CONNECT, rv);
2338 return; 2338 return;
2339 } 2339 }
2340 2340
2341 net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT, 2341 net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT,
2342 base::Bind(&NetLogSSLInfoCallback, base::Unretained(this))); 2342 base::Bind(&NetLogSSLInfoCallback, base::Unretained(this)));
2343 } 2343 }
2344 2344
2345 void SSLClientSocketImpl::RecordNegotiationExtension() const { 2345 void SSLClientSocketImpl::RecordNegotiatedProtocol() const {
2346 if (negotiation_extension_ == kExtensionUnknown) 2346 // Keep this enum in sync with Net.AlpnNegotiatedProtocol histogram.
2347 return; 2347 // Do not change or re-use values.
2348 if (npn_status_ == kNextProtoUnsupported) 2348 enum {
2349 return; 2349 ALPN_NOT_USED = 0,
2350 base::HistogramBase::Sample sample = 2350 ALPN_HTTP11_NEGOTIATED = 1,
2351 static_cast<base::HistogramBase::Sample>(negotiated_protocol_); 2351 ALPN_HTTP2_NEGOTIATED = 2,
2352 // In addition to the protocol negotiated, we want to record which TLS 2352 ALPN_MAX
2353 // extension was used, and in case of NPN, whether there was overlap between 2353 } protocol = ALPN_NOT_USED;
2354 // server and client list of supported protocols. 2354
2355 if (negotiation_extension_ == kExtensionNPN) { 2355 switch (negotiated_protocol_) {
davidben 2016/08/17 19:44:11 Why not just log the kProtoFoo values?
Bence 2016/08/18 13:37:34 Two reasons: (1) I want to fix the values here, cl
davidben 2016/08/25 18:10:41 The enum is small enough that I think it's fine to
Bence 2016/08/27 00:59:46 Done.
2356 if (npn_status_ == kNextProtoNoOverlap) { 2356 case kProtoUnknown:
2357 sample += 1000; 2357 protocol = ALPN_NOT_USED;
davidben 2016/08/17 19:44:11 [Note this will result in a larger histogram, but
davidben 2016/08/17 19:44:56 By the way, this assumes we don't allow unknown AL
Bence 2016/08/18 13:37:34 Acknowledged.
Bence 2016/08/18 13:37:34 I actually consider this an important feature: I w
davidben 2016/08/25 18:10:41 Sounds good.
2358 } else { 2358 break;
2359 sample += 500; 2359 case kProtoHTTP11:
2360 } 2360 protocol = ALPN_HTTP11_NEGOTIATED;
2361 } else { 2361 break;
2362 DCHECK_EQ(kExtensionALPN, negotiation_extension_); 2362 case kProtoHTTP2:
2363 protocol = ALPN_HTTP2_NEGOTIATED;
2364 break;
2365 case kProtoQUIC1SPDY3:
2366 NOTREACHED();
2367 protocol = ALPN_NOT_USED;
2363 } 2368 }
2364 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.SSLProtocolNegotiation", sample); 2369 UMA_HISTOGRAM_ENUMERATION("Net.AlpnNegotiatedProtocol", protocol, ALPN_MAX);
davidben 2016/08/17 19:44:11 Nit: I think it'd be clearest if all the SSL histo
Bence 2016/08/18 13:37:34 Done.
2365 } 2370 }
2366 2371
2367 void SSLClientSocketImpl::RecordChannelIDSupport() const { 2372 void SSLClientSocketImpl::RecordChannelIDSupport() const {
2368 // Since this enum is used for a histogram, do not change or re-use values. 2373 // Since this enum is used for a histogram, do not change or re-use values.
2369 enum { 2374 enum {
2370 DISABLED = 0, 2375 DISABLED = 0,
2371 CLIENT_ONLY = 1, 2376 CLIENT_ONLY = 1,
2372 CLIENT_AND_SERVER = 2, 2377 CLIENT_AND_SERVER = 2,
2373 // CLIENT_NO_ECC is unused now. 2378 // CLIENT_NO_ECC is unused now.
2374 // CLIENT_BAD_SYSTEM_TIME is unused now. 2379 // CLIENT_BAD_SYSTEM_TIME is unused now.
(...skipping 11 matching lines...) Expand all
2386 } 2391 }
2387 UMA_HISTOGRAM_ENUMERATION("DomainBoundCerts.Support", supported, 2392 UMA_HISTOGRAM_ENUMERATION("DomainBoundCerts.Support", supported,
2388 CHANNEL_ID_USAGE_MAX); 2393 CHANNEL_ID_USAGE_MAX);
2389 } 2394 }
2390 2395
2391 bool SSLClientSocketImpl::IsChannelIDEnabled() const { 2396 bool SSLClientSocketImpl::IsChannelIDEnabled() const {
2392 return ssl_config_.channel_id_enabled && channel_id_service_; 2397 return ssl_config_.channel_id_enabled && channel_id_service_;
2393 } 2398 }
2394 2399
2395 } // namespace net 2400 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698