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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 130 |
131 void QuicClientSession::StreamRequest::OnRequestCompleteFailure(int rv) { | 131 void QuicClientSession::StreamRequest::OnRequestCompleteFailure(int rv) { |
132 session_.reset(); | 132 session_.reset(); |
133 ResetAndReturn(&callback_).Run(rv); | 133 ResetAndReturn(&callback_).Run(rv); |
134 } | 134 } |
135 | 135 |
136 QuicClientSession::QuicClientSession( | 136 QuicClientSession::QuicClientSession( |
137 QuicConnection* connection, | 137 QuicConnection* connection, |
138 scoped_ptr<DatagramClientSocket> socket, | 138 scoped_ptr<DatagramClientSocket> socket, |
139 QuicStreamFactory* stream_factory, | 139 QuicStreamFactory* stream_factory, |
140 QuicCryptoClientStreamFactory* crypto_client_stream_factory, | |
141 TransportSecurityState* transport_security_state, | 140 TransportSecurityState* transport_security_state, |
142 scoped_ptr<QuicServerInfo> server_info, | 141 scoped_ptr<QuicServerInfo> server_info, |
143 const QuicServerId& server_id, | |
144 const QuicConfig& config, | 142 const QuicConfig& config, |
145 QuicCryptoClientConfig* crypto_config, | |
146 base::TaskRunner* task_runner, | 143 base::TaskRunner* task_runner, |
147 NetLog* net_log) | 144 NetLog* net_log) |
148 : QuicClientSessionBase(connection, config), | 145 : QuicClientSessionBase(connection, config), |
149 server_host_port_(server_id.host_port_pair()), | |
150 require_confirmation_(false), | 146 require_confirmation_(false), |
151 stream_factory_(stream_factory), | 147 stream_factory_(stream_factory), |
152 socket_(socket.Pass()), | 148 socket_(socket.Pass()), |
153 read_buffer_(new IOBufferWithSize(kMaxPacketSize)), | 149 read_buffer_(new IOBufferWithSize(kMaxPacketSize)), |
154 transport_security_state_(transport_security_state), | 150 transport_security_state_(transport_security_state), |
155 server_info_(server_info.Pass()), | 151 server_info_(server_info.Pass()), |
156 read_pending_(false), | 152 read_pending_(false), |
157 num_total_streams_(0), | 153 num_total_streams_(0), |
158 task_runner_(task_runner), | 154 task_runner_(task_runner), |
159 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_QUIC_SESSION)), | 155 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_QUIC_SESSION)), |
160 logger_(new QuicConnectionLogger(net_log_)), | 156 logger_(new QuicConnectionLogger(net_log_)), |
161 num_packets_read_(0), | 157 num_packets_read_(0), |
162 going_away_(false), | 158 going_away_(false), |
163 weak_factory_(this) { | 159 weak_factory_(this) { |
| 160 connection->set_debug_visitor(logger_); |
| 161 } |
| 162 |
| 163 void QuicClientSession::InitializeSession( |
| 164 const QuicServerId& server_id, |
| 165 QuicCryptoClientConfig* crypto_config, |
| 166 QuicCryptoClientStreamFactory* crypto_client_stream_factory) { |
| 167 server_host_port_.reset(new HostPortPair(server_id.host_port_pair())); |
164 crypto_stream_.reset( | 168 crypto_stream_.reset( |
165 crypto_client_stream_factory ? | 169 crypto_client_stream_factory ? |
166 crypto_client_stream_factory->CreateQuicCryptoClientStream( | 170 crypto_client_stream_factory->CreateQuicCryptoClientStream( |
167 server_id, this, crypto_config) : | 171 server_id, this, crypto_config) : |
168 new QuicCryptoClientStream(server_id, this, | 172 new QuicCryptoClientStream(server_id, this, |
169 new ProofVerifyContextChromium(net_log_), | 173 new ProofVerifyContextChromium(net_log_), |
170 crypto_config)); | 174 crypto_config)); |
171 | 175 QuicClientSessionBase::InitializeSession(); |
172 connection->set_debug_visitor(logger_); | |
173 // TODO(rch): pass in full host port proxy pair | 176 // TODO(rch): pass in full host port proxy pair |
174 net_log_.BeginEvent( | 177 net_log_.BeginEvent( |
175 NetLog::TYPE_QUIC_SESSION, | 178 NetLog::TYPE_QUIC_SESSION, |
176 NetLog::StringCallback("host", &server_id.host())); | 179 NetLog::StringCallback("host", &server_id.host())); |
177 } | 180 } |
178 | 181 |
179 QuicClientSession::~QuicClientSession() { | 182 QuicClientSession::~QuicClientSession() { |
180 if (!streams()->empty()) | 183 if (!streams()->empty()) |
181 RecordUnexpectedOpenStreams(DESTRUCTOR); | 184 RecordUnexpectedOpenStreams(DESTRUCTOR); |
182 if (!observers_.empty()) | 185 if (!observers_.empty()) |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 | 487 |
485 bool QuicClientSession::CanPool(const std::string& hostname) const { | 488 bool QuicClientSession::CanPool(const std::string& hostname) const { |
486 DCHECK(connection()->connected()); | 489 DCHECK(connection()->connected()); |
487 SSLInfo ssl_info; | 490 SSLInfo ssl_info; |
488 if (!GetSSLInfo(&ssl_info) || !ssl_info.cert.get()) { | 491 if (!GetSSLInfo(&ssl_info) || !ssl_info.cert.get()) { |
489 // We can always pool with insecure QUIC sessions. | 492 // We can always pool with insecure QUIC sessions. |
490 return true; | 493 return true; |
491 } | 494 } |
492 | 495 |
493 return SpdySession::CanPool(transport_security_state_, ssl_info, | 496 return SpdySession::CanPool(transport_security_state_, ssl_info, |
494 server_host_port_.host(), hostname); | 497 server_host_port_->host(), hostname); |
495 } | 498 } |
496 | 499 |
497 QuicDataStream* QuicClientSession::CreateIncomingDataStream( | 500 QuicDataStream* QuicClientSession::CreateIncomingDataStream( |
498 QuicStreamId id) { | 501 QuicStreamId id) { |
499 DLOG(ERROR) << "Server push not supported"; | 502 DLOG(ERROR) << "Server push not supported"; |
500 return NULL; | 503 return NULL; |
501 } | 504 } |
502 | 505 |
503 void QuicClientSession::CloseStream(QuicStreamId stream_id) { | 506 void QuicClientSession::CloseStream(QuicStreamId stream_id) { |
504 ReliableQuicStream* stream = GetStream(stream_id); | 507 ReliableQuicStream* stream = GetStream(stream_id); |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 return; | 853 return; |
851 | 854 |
852 // TODO(rch): re-enable this code once beta is cut. | 855 // TODO(rch): re-enable this code once beta is cut. |
853 // if (stream_factory_) | 856 // if (stream_factory_) |
854 // stream_factory_->OnSessionConnectTimeout(this); | 857 // stream_factory_->OnSessionConnectTimeout(this); |
855 // CloseAllStreams(ERR_QUIC_HANDSHAKE_FAILED); | 858 // CloseAllStreams(ERR_QUIC_HANDSHAKE_FAILED); |
856 // DCHECK_EQ(0u, GetNumOpenStreams()); | 859 // DCHECK_EQ(0u, GetNumOpenStreams()); |
857 } | 860 } |
858 | 861 |
859 } // namespace net | 862 } // namespace net |
OLD | NEW |