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" |
| 11 #include "base/profiler/scoped_tracker.h" |
11 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
12 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
13 #include "base/values.h" | 14 #include "base/values.h" |
14 #include "net/base/io_buffer.h" | 15 #include "net/base/io_buffer.h" |
15 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
16 #include "net/base/network_activity_monitor.h" | 17 #include "net/base/network_activity_monitor.h" |
17 #include "net/http/transport_security_state.h" | 18 #include "net/http/transport_security_state.h" |
18 #include "net/quic/crypto/proof_verifier_chromium.h" | 19 #include "net/quic/crypto/proof_verifier_chromium.h" |
19 #include "net/quic/crypto/quic_server_info.h" | 20 #include "net/quic/crypto/quic_server_info.h" |
20 #include "net/quic/quic_connection_helper.h" | 21 #include "net/quic/quic_connection_helper.h" |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 transport_security_state_(transport_security_state), | 169 transport_security_state_(transport_security_state), |
169 server_info_(server_info.Pass()), | 170 server_info_(server_info.Pass()), |
170 read_pending_(false), | 171 read_pending_(false), |
171 num_total_streams_(0), | 172 num_total_streams_(0), |
172 task_runner_(task_runner), | 173 task_runner_(task_runner), |
173 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_QUIC_SESSION)), | 174 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_QUIC_SESSION)), |
174 logger_(new QuicConnectionLogger(this, net_log_)), | 175 logger_(new QuicConnectionLogger(this, net_log_)), |
175 num_packets_read_(0), | 176 num_packets_read_(0), |
176 going_away_(false), | 177 going_away_(false), |
177 weak_factory_(this) { | 178 weak_factory_(this) { |
| 179 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. |
| 180 tracked_objects::ScopedTracker tracking_profile( |
| 181 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 182 "422516 QuicClientSession::QuicClientSession")); |
| 183 |
178 connection->set_debug_visitor(logger_); | 184 connection->set_debug_visitor(logger_); |
179 IPEndPoint address; | 185 IPEndPoint address; |
180 if (socket && socket->GetLocalAddress(&address) == OK && | 186 if (socket && socket->GetLocalAddress(&address) == OK && |
181 address.GetFamily() == ADDRESS_FAMILY_IPV6) { | 187 address.GetFamily() == ADDRESS_FAMILY_IPV6) { |
182 connection->set_max_packet_length( | 188 connection->set_max_packet_length( |
183 connection->max_packet_length() - kAdditionalOverheadForIPv6); | 189 connection->max_packet_length() - kAdditionalOverheadForIPv6); |
184 } | 190 } |
185 } | 191 } |
186 | 192 |
187 void QuicClientSession::InitializeSession( | 193 void QuicClientSession::InitializeSession( |
188 const QuicServerId& server_id, | 194 const QuicServerId& server_id, |
189 QuicCryptoClientConfig* crypto_config, | 195 QuicCryptoClientConfig* crypto_config, |
190 QuicCryptoClientStreamFactory* crypto_client_stream_factory) { | 196 QuicCryptoClientStreamFactory* crypto_client_stream_factory) { |
191 server_host_port_ = server_id.host_port_pair(); | 197 server_id_ = server_id; |
192 crypto_stream_.reset( | 198 crypto_stream_.reset( |
193 crypto_client_stream_factory ? | 199 crypto_client_stream_factory ? |
194 crypto_client_stream_factory->CreateQuicCryptoClientStream( | 200 crypto_client_stream_factory->CreateQuicCryptoClientStream( |
195 server_id, this, crypto_config) : | 201 server_id, this, crypto_config) : |
196 new QuicCryptoClientStream(server_id, this, | 202 new QuicCryptoClientStream(server_id, this, |
197 new ProofVerifyContextChromium(net_log_), | 203 new ProofVerifyContextChromium(net_log_), |
198 crypto_config)); | 204 crypto_config)); |
199 QuicClientSessionBase::InitializeSession(); | 205 QuicClientSessionBase::InitializeSession(); |
200 // TODO(rch): pass in full host port proxy pair | 206 // TODO(rch): pass in full host port proxy pair |
201 net_log_.BeginEvent(NetLog::TYPE_QUIC_SESSION, | 207 net_log_.BeginEvent(NetLog::TYPE_QUIC_SESSION, |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 return ERR_QUIC_HANDSHAKE_FAILED; | 532 return ERR_QUIC_HANDSHAKE_FAILED; |
527 | 533 |
528 callback_ = callback; | 534 callback_ = callback; |
529 return ERR_IO_PENDING; | 535 return ERR_IO_PENDING; |
530 } | 536 } |
531 | 537 |
532 int QuicClientSession::GetNumSentClientHellos() const { | 538 int QuicClientSession::GetNumSentClientHellos() const { |
533 return crypto_stream_->num_sent_client_hellos(); | 539 return crypto_stream_->num_sent_client_hellos(); |
534 } | 540 } |
535 | 541 |
536 bool QuicClientSession::CanPool(const std::string& hostname) const { | 542 bool QuicClientSession::CanPool(const std::string& hostname, |
| 543 PrivacyMode privacy_mode) const { |
537 DCHECK(connection()->connected()); | 544 DCHECK(connection()->connected()); |
| 545 if (privacy_mode != server_id_.privacy_mode()) { |
| 546 // Privacy mode must always match. |
| 547 return false; |
| 548 } |
538 SSLInfo ssl_info; | 549 SSLInfo ssl_info; |
539 if (!GetSSLInfo(&ssl_info) || !ssl_info.cert.get()) { | 550 if (!GetSSLInfo(&ssl_info) || !ssl_info.cert.get()) { |
540 // We can always pool with insecure QUIC sessions. | 551 // We can always pool with insecure QUIC sessions. |
541 return true; | 552 return true; |
542 } | 553 } |
543 | 554 |
544 return SpdySession::CanPool(transport_security_state_, ssl_info, | 555 return SpdySession::CanPool(transport_security_state_, ssl_info, |
545 server_host_port_.host(), hostname); | 556 server_id_.host(), hostname); |
546 } | 557 } |
547 | 558 |
548 QuicDataStream* QuicClientSession::CreateIncomingDataStream( | 559 QuicDataStream* QuicClientSession::CreateIncomingDataStream( |
549 QuicStreamId id) { | 560 QuicStreamId id) { |
550 DLOG(ERROR) << "Server push not supported"; | 561 DLOG(ERROR) << "Server push not supported"; |
551 return nullptr; | 562 return nullptr; |
552 } | 563 } |
553 | 564 |
554 void QuicClientSession::CloseStream(QuicStreamId stream_id) { | 565 void QuicClientSession::CloseStream(QuicStreamId stream_id) { |
555 ReliableQuicStream* stream = GetStream(stream_id); | 566 ReliableQuicStream* stream = GetStream(stream_id); |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
931 return; | 942 return; |
932 | 943 |
933 // TODO(rch): re-enable this code once beta is cut. | 944 // TODO(rch): re-enable this code once beta is cut. |
934 // if (stream_factory_) | 945 // if (stream_factory_) |
935 // stream_factory_->OnSessionConnectTimeout(this); | 946 // stream_factory_->OnSessionConnectTimeout(this); |
936 // CloseAllStreams(ERR_QUIC_HANDSHAKE_FAILED); | 947 // CloseAllStreams(ERR_QUIC_HANDSHAKE_FAILED); |
937 // DCHECK_EQ(0u, GetNumOpenStreams()); | 948 // DCHECK_EQ(0u, GetNumOpenStreams()); |
938 } | 949 } |
939 | 950 |
940 } // namespace net | 951 } // namespace net |
OLD | NEW |