| 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/quic/quic_client_session.h" | 5 #include "net/quic/quic_client_session.h" |
| 6 | 6 |
| 7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/metrics/sparse_histogram.h" | 10 #include "base/metrics/sparse_histogram.h" |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 // Sending one client_hello means we had zero handshake-round-trips. | 225 // Sending one client_hello means we had zero handshake-round-trips. |
| 226 int round_trip_handshakes = crypto_stream_->num_sent_client_hellos() - 1; | 226 int round_trip_handshakes = crypto_stream_->num_sent_client_hellos() - 1; |
| 227 | 227 |
| 228 // Don't bother with these histogram during tests, which mock out | 228 // Don't bother with these histogram during tests, which mock out |
| 229 // num_sent_client_hellos(). | 229 // num_sent_client_hellos(). |
| 230 if (round_trip_handshakes < 0 || !stream_factory_) | 230 if (round_trip_handshakes < 0 || !stream_factory_) |
| 231 return; | 231 return; |
| 232 | 232 |
| 233 bool port_selected = stream_factory_->enable_port_selection(); | 233 bool port_selected = stream_factory_->enable_port_selection(); |
| 234 SSLInfo ssl_info; | 234 SSLInfo ssl_info; |
| 235 if (!GetSSLInfo(&ssl_info) || !ssl_info.cert) { | 235 if (!GetSSLInfo(&ssl_info) || !ssl_info.cert.get()) { |
| 236 if (port_selected) { | 236 if (port_selected) { |
| 237 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.QuicSession.ConnectSelectPortForHTTP", | 237 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.QuicSession.ConnectSelectPortForHTTP", |
| 238 round_trip_handshakes, 0, 3, 4); | 238 round_trip_handshakes, 0, 3, 4); |
| 239 } else { | 239 } else { |
| 240 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.QuicSession.ConnectRandomPortForHTTP", | 240 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.QuicSession.ConnectRandomPortForHTTP", |
| 241 round_trip_handshakes, 0, 3, 4); | 241 round_trip_handshakes, 0, 3, 4); |
| 242 } | 242 } |
| 243 } else { | 243 } else { |
| 244 if (port_selected) { | 244 if (port_selected) { |
| 245 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.QuicSession.ConnectSelectPortForHTTPS", | 245 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.QuicSession.ConnectSelectPortForHTTPS", |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 return ERR_IO_PENDING; | 478 return ERR_IO_PENDING; |
| 479 } | 479 } |
| 480 | 480 |
| 481 int QuicClientSession::GetNumSentClientHellos() const { | 481 int QuicClientSession::GetNumSentClientHellos() const { |
| 482 return crypto_stream_->num_sent_client_hellos(); | 482 return crypto_stream_->num_sent_client_hellos(); |
| 483 } | 483 } |
| 484 | 484 |
| 485 bool QuicClientSession::CanPool(const std::string& hostname) const { | 485 bool QuicClientSession::CanPool(const std::string& hostname) const { |
| 486 DCHECK(connection()->connected()); | 486 DCHECK(connection()->connected()); |
| 487 SSLInfo ssl_info; | 487 SSLInfo ssl_info; |
| 488 if (!GetSSLInfo(&ssl_info) || !ssl_info.cert) { | 488 if (!GetSSLInfo(&ssl_info) || !ssl_info.cert.get()) { |
| 489 // We can always pool with insecure QUIC sessions. | 489 // We can always pool with insecure QUIC sessions. |
| 490 return true; | 490 return true; |
| 491 } | 491 } |
| 492 | 492 |
| 493 return SpdySession::CanPool(transport_security_state_, ssl_info, | 493 return SpdySession::CanPool(transport_security_state_, ssl_info, |
| 494 server_host_port_.host(), hostname); | 494 server_host_port_.host(), hostname); |
| 495 } | 495 } |
| 496 | 496 |
| 497 QuicDataStream* QuicClientSession::CreateIncomingDataStream( | 497 QuicDataStream* QuicClientSession::CreateIncomingDataStream( |
| 498 QuicStreamId id) { | 498 QuicStreamId id) { |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 | 754 |
| 755 dict->SetInteger("total_streams", num_total_streams_); | 755 dict->SetInteger("total_streams", num_total_streams_); |
| 756 dict->SetString("peer_address", peer_address().ToString()); | 756 dict->SetString("peer_address", peer_address().ToString()); |
| 757 dict->SetString("connection_id", base::Uint64ToString(connection_id())); | 757 dict->SetString("connection_id", base::Uint64ToString(connection_id())); |
| 758 dict->SetBoolean("connected", connection()->connected()); | 758 dict->SetBoolean("connected", connection()->connected()); |
| 759 const QuicConnectionStats& stats = connection()->GetStats(); | 759 const QuicConnectionStats& stats = connection()->GetStats(); |
| 760 dict->SetInteger("packets_sent", stats.packets_sent); | 760 dict->SetInteger("packets_sent", stats.packets_sent); |
| 761 dict->SetInteger("packets_received", stats.packets_received); | 761 dict->SetInteger("packets_received", stats.packets_received); |
| 762 dict->SetInteger("packets_lost", stats.packets_lost); | 762 dict->SetInteger("packets_lost", stats.packets_lost); |
| 763 SSLInfo ssl_info; | 763 SSLInfo ssl_info; |
| 764 dict->SetBoolean("secure", GetSSLInfo(&ssl_info) && ssl_info.cert); | 764 dict->SetBoolean("secure", GetSSLInfo(&ssl_info) && ssl_info.cert.get()); |
| 765 | 765 |
| 766 base::ListValue* alias_list = new base::ListValue(); | 766 base::ListValue* alias_list = new base::ListValue(); |
| 767 for (std::set<HostPortPair>::const_iterator it = aliases.begin(); | 767 for (std::set<HostPortPair>::const_iterator it = aliases.begin(); |
| 768 it != aliases.end(); it++) { | 768 it != aliases.end(); it++) { |
| 769 alias_list->Append(new base::StringValue(it->ToString())); | 769 alias_list->Append(new base::StringValue(it->ToString())); |
| 770 } | 770 } |
| 771 dict->Set("aliases", alias_list); | 771 dict->Set("aliases", alias_list); |
| 772 | 772 |
| 773 return dict; | 773 return dict; |
| 774 } | 774 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 return; | 850 return; |
| 851 | 851 |
| 852 // TODO(rch): re-enable this code once beta is cut. | 852 // TODO(rch): re-enable this code once beta is cut. |
| 853 // if (stream_factory_) | 853 // if (stream_factory_) |
| 854 // stream_factory_->OnSessionConnectTimeout(this); | 854 // stream_factory_->OnSessionConnectTimeout(this); |
| 855 // CloseAllStreams(ERR_QUIC_HANDSHAKE_FAILED); | 855 // CloseAllStreams(ERR_QUIC_HANDSHAKE_FAILED); |
| 856 // DCHECK_EQ(0u, GetNumOpenStreams()); | 856 // DCHECK_EQ(0u, GetNumOpenStreams()); |
| 857 } | 857 } |
| 858 | 858 |
| 859 } // namespace net | 859 } // namespace net |
| OLD | NEW |