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

Side by Side Diff: net/quic/quic_stream_factory.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: Added test 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_stream_factory.h" 5 #include "net/quic/quic_stream_factory.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 return stream_.Pass(); 219 return stream_.Pass();
220 } 220 }
221 221
222 int QuicStreamFactory::Job::DoConnect() { 222 int QuicStreamFactory::Job::DoConnect() {
223 io_state_ = STATE_CONNECT_COMPLETE; 223 io_state_ = STATE_CONNECT_COMPLETE;
224 224
225 session_ = factory_->CreateSession(host_port_proxy_pair_, is_https_, 225 session_ = factory_->CreateSession(host_port_proxy_pair_, is_https_,
226 cert_verifier_, address_list_, net_log_); 226 cert_verifier_, address_list_, net_log_);
227 session_->StartReading(); 227 session_->StartReading();
228 int rv = session_->CryptoConnect( 228 int rv = session_->CryptoConnect(
229 factory_->require_confirmation(),
229 base::Bind(&QuicStreamFactory::Job::OnIOComplete, 230 base::Bind(&QuicStreamFactory::Job::OnIOComplete,
230 base::Unretained(this))); 231 base::Unretained(this)));
231 return rv; 232 return rv;
232 } 233 }
233 234
234 int QuicStreamFactory::Job::DoConnectComplete(int rv) { 235 int QuicStreamFactory::Job::DoConnectComplete(int rv) {
235 if (rv != OK) 236 if (rv != OK)
236 return rv; 237 return rv;
237 238
238 DCHECK(!factory_->HasActiveSession(host_port_proxy_pair_)); 239 DCHECK(!factory_->HasActiveSession(host_port_proxy_pair_));
239 factory_->ActivateSession(host_port_proxy_pair_, session_); 240 factory_->ActivateSession(host_port_proxy_pair_, session_);
240 241
241 return OK; 242 return OK;
242 } 243 }
243 244
244 QuicStreamFactory::QuicStreamFactory( 245 QuicStreamFactory::QuicStreamFactory(
245 HostResolver* host_resolver, 246 HostResolver* host_resolver,
246 ClientSocketFactory* client_socket_factory, 247 ClientSocketFactory* client_socket_factory,
247 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory, 248 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory,
248 QuicRandom* random_generator, 249 QuicRandom* random_generator,
249 QuicClock* clock) 250 QuicClock* clock)
250 : host_resolver_(host_resolver), 251 : require_confirmation_(true),
252 host_resolver_(host_resolver),
251 client_socket_factory_(client_socket_factory), 253 client_socket_factory_(client_socket_factory),
252 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory), 254 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory),
253 random_generator_(random_generator), 255 random_generator_(random_generator),
254 clock_(clock), 256 clock_(clock),
255 weak_factory_(this) { 257 weak_factory_(this) {
256 config_.SetDefaults(); 258 config_.SetDefaults();
257 config_.set_idle_connection_state_lifetime( 259 config_.set_idle_connection_state_lifetime(
258 QuicTime::Delta::FromSeconds(30), 260 QuicTime::Delta::FromSeconds(30),
259 QuicTime::Delta::FromSeconds(30)); 261 QuicTime::Delta::FromSeconds(30));
260 } 262 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 } 296 }
295 if (rv == OK) { 297 if (rv == OK) {
296 DCHECK(HasActiveSession(host_port_proxy_pair)); 298 DCHECK(HasActiveSession(host_port_proxy_pair));
297 request->set_stream(CreateIfSessionExists(host_port_proxy_pair, net_log)); 299 request->set_stream(CreateIfSessionExists(host_port_proxy_pair, net_log));
298 } 300 }
299 return rv; 301 return rv;
300 } 302 }
301 303
302 void QuicStreamFactory::OnJobComplete(Job* job, int rv) { 304 void QuicStreamFactory::OnJobComplete(Job* job, int rv) {
303 if (rv == OK) { 305 if (rv == OK) {
306 require_confirmation_ = false;
304 // Create all the streams, but do not notify them yet. 307 // Create all the streams, but do not notify them yet.
305 for (RequestSet::iterator it = job_requests_map_[job].begin(); 308 for (RequestSet::iterator it = job_requests_map_[job].begin();
306 it != job_requests_map_[job].end() ; ++it) { 309 it != job_requests_map_[job].end() ; ++it) {
307 DCHECK(HasActiveSession(job->host_port_proxy_pair())); 310 DCHECK(HasActiveSession(job->host_port_proxy_pair()));
308 (*it)->set_stream(CreateIfSessionExists(job->host_port_proxy_pair(), 311 (*it)->set_stream(CreateIfSessionExists(job->host_port_proxy_pair(),
309 (*it)->net_log())); 312 (*it)->net_log()));
310 } 313 }
311 } 314 }
312 while (!job_requests_map_[job].empty()) { 315 while (!job_requests_map_[job].empty()) {
313 RequestSet::iterator it = job_requests_map_[job].begin(); 316 RequestSet::iterator it = job_requests_map_[job].begin();
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 const HostPortProxyPair& pair = it->first; 389 const HostPortProxyPair& pair = it->first;
387 const QuicClientSession* session = it->second; 390 const QuicClientSession* session = it->second;
388 391
389 list->Append(session->GetInfoAsValue(pair.first)); 392 list->Append(session->GetInfoAsValue(pair.first));
390 } 393 }
391 return list; 394 return list;
392 } 395 }
393 396
394 void QuicStreamFactory::OnIPAddressChanged() { 397 void QuicStreamFactory::OnIPAddressChanged() {
395 CloseAllSessions(ERR_NETWORK_CHANGED); 398 CloseAllSessions(ERR_NETWORK_CHANGED);
399 require_confirmation_ = true;
396 } 400 }
397 401
398 bool QuicStreamFactory::HasActiveSession( 402 bool QuicStreamFactory::HasActiveSession(
399 const HostPortProxyPair& host_port_proxy_pair) { 403 const HostPortProxyPair& host_port_proxy_pair) {
400 return ContainsKey(active_sessions_, host_port_proxy_pair); 404 return ContainsKey(active_sessions_, host_port_proxy_pair);
401 } 405 }
402 406
403 QuicClientSession* QuicStreamFactory::CreateSession( 407 QuicClientSession* QuicStreamFactory::CreateSession(
404 const HostPortProxyPair& host_port_proxy_pair, 408 const HostPortProxyPair& host_port_proxy_pair,
405 bool is_https, 409 bool is_https,
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 DCHECK(crypto_config); 484 DCHECK(crypto_config);
481 } else { 485 } else {
482 crypto_config = new QuicCryptoClientConfig(); 486 crypto_config = new QuicCryptoClientConfig();
483 crypto_config->SetDefaults(); 487 crypto_config->SetDefaults();
484 all_crypto_configs_[host_port_proxy_pair] = crypto_config; 488 all_crypto_configs_[host_port_proxy_pair] = crypto_config;
485 } 489 }
486 return crypto_config; 490 return crypto_config;
487 } 491 }
488 492
489 } // namespace net 493 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698