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

Side by Side Diff: net/quic/quic_client_session.cc

Issue 393953009: Moving the work currently done in the QuicSession constructor to (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_client_session.h ('k') | net/quic/quic_client_session_test.cc » ('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/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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 session_.reset(); 125 session_.reset();
126 *stream_ = stream; 126 *stream_ = stream;
127 ResetAndReturn(&callback_).Run(OK); 127 ResetAndReturn(&callback_).Run(OK);
128 } 128 }
129 129
130 void QuicClientSession::StreamRequest::OnRequestCompleteFailure(int rv) { 130 void QuicClientSession::StreamRequest::OnRequestCompleteFailure(int rv) {
131 session_.reset(); 131 session_.reset();
132 ResetAndReturn(&callback_).Run(rv); 132 ResetAndReturn(&callback_).Run(rv);
133 } 133 }
134 134
135 QuicClientSession::QuicClientSession( 135 QuicClientSession::QuicClientSession(QuicConnection* connection,
136 QuicConnection* connection, 136 scoped_ptr<DatagramClientSocket> socket,
137 scoped_ptr<DatagramClientSocket> socket, 137 scoped_ptr<QuicDefaultPacketWriter> writer,
138 scoped_ptr<QuicDefaultPacketWriter> writer, 138 QuicStreamFactory* stream_factory,
139 QuicStreamFactory* stream_factory, 139 scoped_ptr<QuicServerInfo> server_info,
140 QuicCryptoClientStreamFactory* crypto_client_stream_factory, 140 const QuicConfig& config,
141 scoped_ptr<QuicServerInfo> server_info, 141 base::TaskRunner* task_runner,
142 const QuicServerId& server_id, 142 NetLog* net_log)
143 const QuicConfig& config, 143 : QuicClientSessionBase(connection, config),
144 QuicCryptoClientConfig* crypto_config,
145 base::TaskRunner* task_runner,
146 NetLog* net_log)
147 : QuicClientSessionBase(connection,
148 config),
149 server_host_port_(server_id.host_port_pair()),
150 require_confirmation_(false), 144 require_confirmation_(false),
151 stream_factory_(stream_factory), 145 stream_factory_(stream_factory),
152 socket_(socket.Pass()), 146 socket_(socket.Pass()),
153 writer_(writer.Pass()), 147 writer_(writer.Pass()),
154 read_buffer_(new IOBufferWithSize(kMaxPacketSize)), 148 read_buffer_(new IOBufferWithSize(kMaxPacketSize)),
155 server_info_(server_info.Pass()), 149 server_info_(server_info.Pass()),
156 read_pending_(false), 150 read_pending_(false),
157 num_total_streams_(0), 151 num_total_streams_(0),
158 task_runner_(task_runner), 152 task_runner_(task_runner),
159 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_QUIC_SESSION)), 153 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_QUIC_SESSION)),
160 logger_(net_log_), 154 logger_(net_log_),
161 num_packets_read_(0), 155 num_packets_read_(0),
162 going_away_(false), 156 going_away_(false),
163 weak_factory_(this) { 157 weak_factory_(this) {
158 connection->set_debug_visitor(&logger_);
159 }
160
161 void QuicClientSession::InitializeSession(
162 const QuicServerId& server_id,
163 QuicCryptoClientConfig* crypto_config,
164 QuicCryptoClientStreamFactory* crypto_client_stream_factory) {
165 QuicClientSessionBase::InitializeSession();
ramant (doing other things) 2014/07/16 03:22:57 Hi Ryan, Tried to keep this class similar to ser
Ryan Hamilton 2014/07/16 15:53:32 Seems reasonable to me!
166 server_host_port_.reset(new HostPortPair(server_id.host_port_pair()));
164 crypto_stream_.reset( 167 crypto_stream_.reset(
165 crypto_client_stream_factory ? 168 crypto_client_stream_factory ?
166 crypto_client_stream_factory->CreateQuicCryptoClientStream( 169 crypto_client_stream_factory->CreateQuicCryptoClientStream(
167 server_id, this, crypto_config) : 170 server_id, this, crypto_config) :
168 new QuicCryptoClientStream(server_id, this, 171 new QuicCryptoClientStream(server_id, this,
169 new ProofVerifyContextChromium(net_log_), 172 new ProofVerifyContextChromium(net_log_),
170 crypto_config)); 173 crypto_config));
171 174
172 connection->set_debug_visitor(&logger_);
173 // TODO(rch): pass in full host port proxy pair 175 // TODO(rch): pass in full host port proxy pair
174 net_log_.BeginEvent( 176 net_log_.BeginEvent(
175 NetLog::TYPE_QUIC_SESSION, 177 NetLog::TYPE_QUIC_SESSION,
176 NetLog::StringCallback("host", &server_id.host())); 178 NetLog::StringCallback("host", &server_id.host()));
177 } 179 }
178 180
179 QuicClientSession::~QuicClientSession() { 181 QuicClientSession::~QuicClientSession() {
180 if (!streams()->empty()) 182 if (!streams()->empty())
181 RecordUnexpectedOpenStreams(DESTRUCTOR); 183 RecordUnexpectedOpenStreams(DESTRUCTOR);
182 if (!observers_.empty()) 184 if (!observers_.empty())
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 ssl_info->security_bits = security_bits; 432 ssl_info->security_bits = security_bits;
431 ssl_info->handshake_type = SSLInfo::HANDSHAKE_FULL; 433 ssl_info->handshake_type = SSLInfo::HANDSHAKE_FULL;
432 return true; 434 return true;
433 } 435 }
434 436
435 int QuicClientSession::CryptoConnect(bool require_confirmation, 437 int QuicClientSession::CryptoConnect(bool require_confirmation,
436 const CompletionCallback& callback) { 438 const CompletionCallback& callback) {
437 require_confirmation_ = require_confirmation; 439 require_confirmation_ = require_confirmation;
438 handshake_start_ = base::TimeTicks::Now(); 440 handshake_start_ = base::TimeTicks::Now();
439 RecordHandshakeState(STATE_STARTED); 441 RecordHandshakeState(STATE_STARTED);
442 DCHECK(flow_controller());
440 if (!crypto_stream_->CryptoConnect()) { 443 if (!crypto_stream_->CryptoConnect()) {
441 // TODO(wtc): change crypto_stream_.CryptoConnect() to return a 444 // TODO(wtc): change crypto_stream_.CryptoConnect() to return a
442 // QuicErrorCode and map it to a net error code. 445 // QuicErrorCode and map it to a net error code.
443 return ERR_CONNECTION_FAILED; 446 return ERR_CONNECTION_FAILED;
444 } 447 }
445 448
446 if (IsCryptoHandshakeConfirmed()) 449 if (IsCryptoHandshakeConfirmed())
447 return OK; 450 return OK;
448 451
449 // Unless we require handshake confirmation, activate the session if 452 // Unless we require handshake confirmation, activate the session if
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 // and for connections on which client certs were sent. It is also prohibited 496 // and for connections on which client certs were sent. It is also prohibited
494 // when channel ID was sent if the hosts are from different eTLDs+1. 497 // when channel ID was sent if the hosts are from different eTLDs+1.
495 if (!ssl_info.cert->VerifyNameMatch(hostname, &unused)) 498 if (!ssl_info.cert->VerifyNameMatch(hostname, &unused))
496 return false; 499 return false;
497 500
498 if (ssl_info.client_cert_sent) 501 if (ssl_info.client_cert_sent)
499 return false; 502 return false;
500 503
501 if (ssl_info.channel_id_sent && 504 if (ssl_info.channel_id_sent &&
502 ServerBoundCertService::GetDomainForHost(hostname) != 505 ServerBoundCertService::GetDomainForHost(hostname) !=
503 ServerBoundCertService::GetDomainForHost(server_host_port_.host())) { 506 ServerBoundCertService::GetDomainForHost(server_host_port_->host())) {
504 return false; 507 return false;
505 } 508 }
506 509
507 return true; 510 return true;
508 } 511 }
509 512
510 QuicDataStream* QuicClientSession::CreateIncomingDataStream( 513 QuicDataStream* QuicClientSession::CreateIncomingDataStream(
511 QuicStreamId id) { 514 QuicStreamId id) {
512 DLOG(ERROR) << "Server push not supported"; 515 DLOG(ERROR) << "Server push not supported";
513 return NULL; 516 return NULL;
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « net/quic/quic_client_session.h ('k') | net/quic/quic_client_session_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698