Chromium Code Reviews| 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_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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 220 return stream_.Pass(); | 220 return stream_.Pass(); |
| 221 } | 221 } |
| 222 | 222 |
| 223 int QuicStreamFactory::Job::DoConnect() { | 223 int QuicStreamFactory::Job::DoConnect() { |
| 224 io_state_ = STATE_CONNECT_COMPLETE; | 224 io_state_ = STATE_CONNECT_COMPLETE; |
| 225 | 225 |
| 226 session_ = factory_->CreateSession(host_port_proxy_pair_, is_https_, | 226 session_ = factory_->CreateSession(host_port_proxy_pair_, is_https_, |
| 227 cert_verifier_, address_list_, net_log_); | 227 cert_verifier_, address_list_, net_log_); |
| 228 session_->StartReading(); | 228 session_->StartReading(); |
| 229 int rv = session_->CryptoConnect( | 229 int rv = session_->CryptoConnect( |
| 230 factory_->require_confirmation(), | |
| 230 base::Bind(&QuicStreamFactory::Job::OnIOComplete, | 231 base::Bind(&QuicStreamFactory::Job::OnIOComplete, |
| 231 base::Unretained(this))); | 232 base::Unretained(this))); |
| 232 return rv; | 233 return rv; |
| 233 } | 234 } |
| 234 | 235 |
| 235 int QuicStreamFactory::Job::DoConnectComplete(int rv) { | 236 int QuicStreamFactory::Job::DoConnectComplete(int rv) { |
| 236 if (rv != OK) | 237 if (rv != OK) |
| 237 return rv; | 238 return rv; |
| 238 | 239 |
| 239 DCHECK(!factory_->HasActiveSession(host_port_proxy_pair_)); | 240 DCHECK(!factory_->HasActiveSession(host_port_proxy_pair_)); |
| 240 factory_->ActivateSession(host_port_proxy_pair_, session_); | 241 factory_->ActivateSession(host_port_proxy_pair_, session_); |
| 241 | 242 |
| 242 return OK; | 243 return OK; |
| 243 } | 244 } |
| 244 | 245 |
| 245 QuicStreamFactory::QuicStreamFactory( | 246 QuicStreamFactory::QuicStreamFactory( |
| 246 HostResolver* host_resolver, | 247 HostResolver* host_resolver, |
| 247 ClientSocketFactory* client_socket_factory, | 248 ClientSocketFactory* client_socket_factory, |
| 248 base::WeakPtr<HttpServerProperties> http_server_properties, | 249 base::WeakPtr<HttpServerProperties> http_server_properties, |
| 249 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory, | 250 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory, |
| 250 QuicRandom* random_generator, | 251 QuicRandom* random_generator, |
| 251 QuicClock* clock) | 252 QuicClock* clock) |
| 252 : host_resolver_(host_resolver), | 253 : require_confirmation_(true), |
|
wtc
2013/08/21 01:09:32
Can you explain why require_confirmation_ should b
| |
| 254 host_resolver_(host_resolver), | |
| 253 client_socket_factory_(client_socket_factory), | 255 client_socket_factory_(client_socket_factory), |
| 254 http_server_properties_(http_server_properties), | 256 http_server_properties_(http_server_properties), |
| 255 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory), | 257 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory), |
| 256 random_generator_(random_generator), | 258 random_generator_(random_generator), |
| 257 clock_(clock), | 259 clock_(clock), |
| 258 weak_factory_(this) { | 260 weak_factory_(this) { |
| 259 config_.SetDefaults(); | 261 config_.SetDefaults(); |
| 260 config_.set_idle_connection_state_lifetime( | 262 config_.set_idle_connection_state_lifetime( |
| 261 QuicTime::Delta::FromSeconds(30), | 263 QuicTime::Delta::FromSeconds(30), |
| 262 QuicTime::Delta::FromSeconds(30)); | 264 QuicTime::Delta::FromSeconds(30)); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 288 scoped_ptr<Job> job(new Job(this, host_resolver_, host_port_proxy_pair, | 290 scoped_ptr<Job> job(new Job(this, host_resolver_, host_port_proxy_pair, |
| 289 is_https, cert_verifier, net_log)); | 291 is_https, cert_verifier, net_log)); |
| 290 int rv = job->Run(base::Bind(&QuicStreamFactory::OnJobComplete, | 292 int rv = job->Run(base::Bind(&QuicStreamFactory::OnJobComplete, |
| 291 base::Unretained(this), job.get())); | 293 base::Unretained(this), job.get())); |
| 292 | 294 |
| 293 if (rv == ERR_IO_PENDING) { | 295 if (rv == ERR_IO_PENDING) { |
| 294 active_requests_[request] = job.get(); | 296 active_requests_[request] = job.get(); |
| 295 job_requests_map_[job.get()].insert(request); | 297 job_requests_map_[job.get()].insert(request); |
| 296 active_jobs_[host_port_proxy_pair] = job.release(); | 298 active_jobs_[host_port_proxy_pair] = job.release(); |
| 297 } | 299 } |
| 298 if (rv == OK) { | 300 if (rv == OK) { |
|
wtc
2013/08/21 01:09:32
Should we also set require_confirmation_ to false
| |
| 299 DCHECK(HasActiveSession(host_port_proxy_pair)); | 301 DCHECK(HasActiveSession(host_port_proxy_pair)); |
| 300 request->set_stream(CreateIfSessionExists(host_port_proxy_pair, net_log)); | 302 request->set_stream(CreateIfSessionExists(host_port_proxy_pair, net_log)); |
| 301 } | 303 } |
| 302 return rv; | 304 return rv; |
| 303 } | 305 } |
| 304 | 306 |
| 305 void QuicStreamFactory::OnJobComplete(Job* job, int rv) { | 307 void QuicStreamFactory::OnJobComplete(Job* job, int rv) { |
| 306 if (rv == OK) { | 308 if (rv == OK) { |
| 309 require_confirmation_ = false; | |
| 307 // Create all the streams, but do not notify them yet. | 310 // Create all the streams, but do not notify them yet. |
| 308 for (RequestSet::iterator it = job_requests_map_[job].begin(); | 311 for (RequestSet::iterator it = job_requests_map_[job].begin(); |
| 309 it != job_requests_map_[job].end() ; ++it) { | 312 it != job_requests_map_[job].end() ; ++it) { |
| 310 DCHECK(HasActiveSession(job->host_port_proxy_pair())); | 313 DCHECK(HasActiveSession(job->host_port_proxy_pair())); |
| 311 (*it)->set_stream(CreateIfSessionExists(job->host_port_proxy_pair(), | 314 (*it)->set_stream(CreateIfSessionExists(job->host_port_proxy_pair(), |
| 312 (*it)->net_log())); | 315 (*it)->net_log())); |
| 313 } | 316 } |
| 314 } | 317 } |
| 315 while (!job_requests_map_[job].empty()) { | 318 while (!job_requests_map_[job].empty()) { |
| 316 RequestSet::iterator it = job_requests_map_[job].begin(); | 319 RequestSet::iterator it = job_requests_map_[job].begin(); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 396 const HostPortProxyPair& pair = it->first; | 399 const HostPortProxyPair& pair = it->first; |
| 397 const QuicClientSession* session = it->second; | 400 const QuicClientSession* session = it->second; |
| 398 | 401 |
| 399 list->Append(session->GetInfoAsValue(pair.first)); | 402 list->Append(session->GetInfoAsValue(pair.first)); |
| 400 } | 403 } |
| 401 return list; | 404 return list; |
| 402 } | 405 } |
| 403 | 406 |
| 404 void QuicStreamFactory::OnIPAddressChanged() { | 407 void QuicStreamFactory::OnIPAddressChanged() { |
| 405 CloseAllSessions(ERR_NETWORK_CHANGED); | 408 CloseAllSessions(ERR_NETWORK_CHANGED); |
| 409 require_confirmation_ = true; | |
| 406 } | 410 } |
| 407 | 411 |
| 408 bool QuicStreamFactory::HasActiveSession( | 412 bool QuicStreamFactory::HasActiveSession( |
| 409 const HostPortProxyPair& host_port_proxy_pair) { | 413 const HostPortProxyPair& host_port_proxy_pair) { |
| 410 return ContainsKey(active_sessions_, host_port_proxy_pair); | 414 return ContainsKey(active_sessions_, host_port_proxy_pair); |
| 411 } | 415 } |
| 412 | 416 |
| 413 QuicClientSession* QuicStreamFactory::CreateSession( | 417 QuicClientSession* QuicStreamFactory::CreateSession( |
| 414 const HostPortProxyPair& host_port_proxy_pair, | 418 const HostPortProxyPair& host_port_proxy_pair, |
| 415 bool is_https, | 419 bool is_https, |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 490 DCHECK(crypto_config); | 494 DCHECK(crypto_config); |
| 491 } else { | 495 } else { |
| 492 crypto_config = new QuicCryptoClientConfig(); | 496 crypto_config = new QuicCryptoClientConfig(); |
| 493 crypto_config->SetDefaults(); | 497 crypto_config->SetDefaults(); |
| 494 all_crypto_configs_[host_port_proxy_pair] = crypto_config; | 498 all_crypto_configs_[host_port_proxy_pair] = crypto_config; |
| 495 } | 499 } |
| 496 return crypto_config; | 500 return crypto_config; |
| 497 } | 501 } |
| 498 | 502 |
| 499 } // namespace net | 503 } // namespace net |
| OLD | NEW |