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

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

Issue 23279011: Require handshake confirmation until a QUIC connection is created succesfully when using a new netw… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Created 7 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 | Annotate | Revision Log
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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 QuicClientSession::QuicClientSession( 82 QuicClientSession::QuicClientSession(
83 QuicConnection* connection, 83 QuicConnection* connection,
84 scoped_ptr<DatagramClientSocket> socket, 84 scoped_ptr<DatagramClientSocket> socket,
85 QuicStreamFactory* stream_factory, 85 QuicStreamFactory* stream_factory,
86 QuicCryptoClientStreamFactory* crypto_client_stream_factory, 86 QuicCryptoClientStreamFactory* crypto_client_stream_factory,
87 const string& server_hostname, 87 const string& server_hostname,
88 const QuicConfig& config, 88 const QuicConfig& config,
89 QuicCryptoClientConfig* crypto_config, 89 QuicCryptoClientConfig* crypto_config,
90 NetLog* net_log) 90 NetLog* net_log)
91 : QuicSession(connection, config, false), 91 : QuicSession(connection, config, false),
92 weak_factory_(this), 92 require_confirmation_(false),
93 stream_factory_(stream_factory), 93 stream_factory_(stream_factory),
94 socket_(socket.Pass()), 94 socket_(socket.Pass()),
95 read_buffer_(new IOBufferWithSize(kMaxPacketSize)), 95 read_buffer_(new IOBufferWithSize(kMaxPacketSize)),
96 read_pending_(false), 96 read_pending_(false),
97 num_total_streams_(0), 97 num_total_streams_(0),
98 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_QUIC_SESSION)), 98 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_QUIC_SESSION)),
99 logger_(net_log_) { 99 logger_(net_log_),
100 weak_factory_(this) {
100 crypto_stream_.reset( 101 crypto_stream_.reset(
101 crypto_client_stream_factory ? 102 crypto_client_stream_factory ?
102 crypto_client_stream_factory->CreateQuicCryptoClientStream( 103 crypto_client_stream_factory->CreateQuicCryptoClientStream(
103 server_hostname, this, crypto_config) : 104 server_hostname, this, crypto_config) :
104 new QuicCryptoClientStream(server_hostname, this, crypto_config)); 105 new QuicCryptoClientStream(server_hostname, this, crypto_config));
105 106
106 connection->set_debug_visitor(&logger_); 107 connection->set_debug_visitor(&logger_);
107 // TODO(rch): pass in full host port proxy pair 108 // TODO(rch): pass in full host port proxy pair
108 net_log_.BeginEvent( 109 net_log_.BeginEvent(
109 NetLog::TYPE_QUIC_SESSION, 110 NetLog::TYPE_QUIC_SESSION,
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 203
203 QuicCryptoClientStream* QuicClientSession::GetCryptoStream() { 204 QuicCryptoClientStream* QuicClientSession::GetCryptoStream() {
204 return crypto_stream_.get(); 205 return crypto_stream_.get();
205 }; 206 };
206 207
207 bool QuicClientSession::GetSSLInfo(SSLInfo* ssl_info) { 208 bool QuicClientSession::GetSSLInfo(SSLInfo* ssl_info) {
208 DCHECK(crypto_stream_.get()); 209 DCHECK(crypto_stream_.get());
209 return crypto_stream_->GetSSLInfo(ssl_info); 210 return crypto_stream_->GetSSLInfo(ssl_info);
210 } 211 }
211 212
212 int QuicClientSession::CryptoConnect(const CompletionCallback& callback) { 213 int QuicClientSession::CryptoConnect(bool require_confirmation,
214 const CompletionCallback& callback) {
215 require_confirmation_ = require_confirmation;
213 RecordHandshakeState(STATE_STARTED); 216 RecordHandshakeState(STATE_STARTED);
214 if (!crypto_stream_->CryptoConnect()) { 217 if (!crypto_stream_->CryptoConnect()) {
215 // TODO(wtc): change crypto_stream_.CryptoConnect() to return a 218 // TODO(wtc): change crypto_stream_.CryptoConnect() to return a
216 // QuicErrorCode and map it to a net error code. 219 // QuicErrorCode and map it to a net error code.
217 return ERR_CONNECTION_FAILED; 220 return ERR_CONNECTION_FAILED;
218 } 221 }
219 222
220 if (IsEncryptionEstablished()) { 223 bool can_notify = require_confirmation_ ?
224 IsCryptoHandshakeConfirmed() : IsEncryptionEstablished();
225 if (can_notify) {
221 return OK; 226 return OK;
222 } 227 }
223 228
224 callback_ = callback; 229 callback_ = callback;
225 return ERR_IO_PENDING; 230 return ERR_IO_PENDING;
226 } 231 }
227 232
228 ReliableQuicStream* QuicClientSession::CreateIncomingReliableStream( 233 ReliableQuicStream* QuicClientSession::CreateIncomingReliableStream(
229 QuicStreamId id) { 234 QuicStreamId id) {
230 DLOG(ERROR) << "Server push not supported"; 235 DLOG(ERROR) << "Server push not supported";
(...skipping 12 matching lines...) Expand all
243 stream_requests_.pop_front(); 248 stream_requests_.pop_front();
244 request->OnRequestCompleteSuccess(CreateOutgoingReliableStreamImpl()); 249 request->OnRequestCompleteSuccess(CreateOutgoingReliableStreamImpl());
245 } 250 }
246 251
247 if (GetNumOpenStreams() == 0) { 252 if (GetNumOpenStreams() == 0) {
248 stream_factory_->OnIdleSession(this); 253 stream_factory_->OnIdleSession(this);
249 } 254 }
250 } 255 }
251 256
252 void QuicClientSession::OnCryptoHandshakeEvent(CryptoHandshakeEvent event) { 257 void QuicClientSession::OnCryptoHandshakeEvent(CryptoHandshakeEvent event) {
253 if (!callback_.is_null()) { 258 if (!callback_.is_null() &&
259 (!require_confirmation_ || event == HANDSHAKE_CONFIRMED)) {
254 // TODO(rtenneti): Currently for all CryptoHandshakeEvent events, callback_ 260 // TODO(rtenneti): Currently for all CryptoHandshakeEvent events, callback_
255 // could be called because there are no error events in CryptoHandshakeEvent 261 // could be called because there are no error events in CryptoHandshakeEvent
256 // enum. If error events are added to CryptoHandshakeEvent, then the 262 // enum. If error events are added to CryptoHandshakeEvent, then the
257 // following code needs to changed. 263 // following code needs to changed.
258 base::ResetAndReturn(&callback_).Run(OK); 264 base::ResetAndReturn(&callback_).Run(OK);
259 } 265 }
260 QuicSession::OnCryptoHandshakeEvent(event); 266 QuicSession::OnCryptoHandshakeEvent(event);
wtc 2013/08/21 01:09:32 An unrelated question: have you thought about the
261 } 267 }
262 268
263 void QuicClientSession::OnCryptoHandshakeMessageSent( 269 void QuicClientSession::OnCryptoHandshakeMessageSent(
264 const CryptoHandshakeMessage& message) { 270 const CryptoHandshakeMessage& message) {
265 logger_.OnCryptoHandshakeMessageSent(message); 271 logger_.OnCryptoHandshakeMessageSent(message);
266 } 272 }
267 273
268 void QuicClientSession::OnCryptoHandshakeMessageReceived( 274 void QuicClientSession::OnCryptoHandshakeMessageReceived(
269 const CryptoHandshakeMessage& message) { 275 const CryptoHandshakeMessage& message) {
270 logger_.OnCryptoHandshakeMessageReceived(message); 276 logger_.OnCryptoHandshakeMessageReceived(message);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 } 389 }
384 390
385 void QuicClientSession::NotifyFactoryOfSessionClose() { 391 void QuicClientSession::NotifyFactoryOfSessionClose() {
386 DCHECK_EQ(0u, GetNumOpenStreams()); 392 DCHECK_EQ(0u, GetNumOpenStreams());
387 DCHECK(stream_factory_); 393 DCHECK(stream_factory_);
388 // Will delete |this|. 394 // Will delete |this|.
389 stream_factory_->OnSessionClose(this); 395 stream_factory_->OnSessionClose(this);
390 } 396 }
391 397
392 } // namespace net 398 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698