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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 return OK; | 320 return OK; |
321 } | 321 } |
322 | 322 |
323 if (HasActiveJob(host_port_proxy_pair)) { | 323 if (HasActiveJob(host_port_proxy_pair)) { |
324 Job* job = active_jobs_[host_port_proxy_pair]; | 324 Job* job = active_jobs_[host_port_proxy_pair]; |
325 active_requests_[request] = job; | 325 active_requests_[request] = job; |
326 job_requests_map_[job].insert(request); | 326 job_requests_map_[job].insert(request); |
327 return ERR_IO_PENDING; | 327 return ERR_IO_PENDING; |
328 } | 328 } |
329 | 329 |
| 330 // Create crypto config and start the process of loading QUIC server |
| 331 // information from disk cache. |
| 332 QuicCryptoClientConfig* crypto_config = |
| 333 GetOrCreateCryptoConfig(host_port_proxy_pair); |
| 334 DCHECK(crypto_config); |
| 335 |
330 scoped_ptr<Job> job(new Job(this, host_resolver_, host_port_proxy_pair, | 336 scoped_ptr<Job> job(new Job(this, host_resolver_, host_port_proxy_pair, |
331 is_https, cert_verifier, net_log)); | 337 is_https, cert_verifier, net_log)); |
332 int rv = job->Run(base::Bind(&QuicStreamFactory::OnJobComplete, | 338 int rv = job->Run(base::Bind(&QuicStreamFactory::OnJobComplete, |
333 base::Unretained(this), job.get())); | 339 base::Unretained(this), job.get())); |
334 | 340 |
335 if (rv == ERR_IO_PENDING) { | 341 if (rv == ERR_IO_PENDING) { |
336 active_requests_[request] = job.get(); | 342 active_requests_[request] = job.get(); |
337 job_requests_map_[job.get()].insert(request); | 343 job_requests_map_[job.get()].insert(request); |
338 active_jobs_[host_port_proxy_pair] = job.release(); | 344 active_jobs_[host_port_proxy_pair] = job.release(); |
339 } | 345 } |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 QuicCryptoClientConfig* QuicStreamFactory::GetOrCreateCryptoConfig( | 626 QuicCryptoClientConfig* QuicStreamFactory::GetOrCreateCryptoConfig( |
621 const HostPortProxyPair& host_port_proxy_pair) { | 627 const HostPortProxyPair& host_port_proxy_pair) { |
622 QuicCryptoClientConfig* crypto_config; | 628 QuicCryptoClientConfig* crypto_config; |
623 | 629 |
624 if (ContainsKey(all_crypto_configs_, host_port_proxy_pair)) { | 630 if (ContainsKey(all_crypto_configs_, host_port_proxy_pair)) { |
625 crypto_config = all_crypto_configs_[host_port_proxy_pair]; | 631 crypto_config = all_crypto_configs_[host_port_proxy_pair]; |
626 DCHECK(crypto_config); | 632 DCHECK(crypto_config); |
627 } else { | 633 } else { |
628 // TODO(rtenneti): if two quic_sessions for the same host_port_proxy_pair | 634 // TODO(rtenneti): if two quic_sessions for the same host_port_proxy_pair |
629 // share the same crypto_config, will it cause issues? | 635 // share the same crypto_config, will it cause issues? |
630 crypto_config = new QuicCryptoClientConfig(quic_server_info_factory_); | 636 crypto_config = new QuicCryptoClientConfig(); |
| 637 if (quic_server_info_factory_) { |
| 638 QuicCryptoClientConfig::CachedState* cached = |
| 639 crypto_config->Create(host_port_proxy_pair.first.host(), |
| 640 quic_server_info_factory_); |
| 641 DCHECK(cached); |
| 642 } |
631 crypto_config->SetDefaults(); | 643 crypto_config->SetDefaults(); |
632 all_crypto_configs_[host_port_proxy_pair] = crypto_config; | 644 all_crypto_configs_[host_port_proxy_pair] = crypto_config; |
633 PopulateFromCanonicalConfig(host_port_proxy_pair, crypto_config); | 645 PopulateFromCanonicalConfig(host_port_proxy_pair, crypto_config); |
634 } | 646 } |
635 return crypto_config; | 647 return crypto_config; |
636 } | 648 } |
637 | 649 |
638 void QuicStreamFactory::PopulateFromCanonicalConfig( | 650 void QuicStreamFactory::PopulateFromCanonicalConfig( |
639 const HostPortProxyPair& host_port_proxy_pair, | 651 const HostPortProxyPair& host_port_proxy_pair, |
640 QuicCryptoClientConfig* crypto_config) { | 652 QuicCryptoClientConfig* crypto_config) { |
(...skipping 27 matching lines...) Expand all Loading... |
668 // Copy the CachedState for the canonical server from canonical_crypto_config | 680 // Copy the CachedState for the canonical server from canonical_crypto_config |
669 // as the initial CachedState for the server_hostname in crypto_config. | 681 // as the initial CachedState for the server_hostname in crypto_config. |
670 crypto_config->InitializeFrom(server_hostname, | 682 crypto_config->InitializeFrom(server_hostname, |
671 canonical_host_port_proxy_pair.first.host(), | 683 canonical_host_port_proxy_pair.first.host(), |
672 canonical_crypto_config); | 684 canonical_crypto_config); |
673 // Update canonical version to point at the "most recent" crypto_config. | 685 // Update canonical version to point at the "most recent" crypto_config. |
674 canonical_hostname_to_origin_map_[canonical_host_port] = host_port_proxy_pair; | 686 canonical_hostname_to_origin_map_[canonical_host_port] = host_port_proxy_pair; |
675 } | 687 } |
676 | 688 |
677 } // namespace net | 689 } // namespace net |
OLD | NEW |