| 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_crypto_client_stream.h" | 5 #include "net/quic/quic_crypto_client_stream.h" |
| 6 | 6 |
| 7 #include "net/base/completion_callback.h" | 7 #include "net/base/completion_callback.h" |
| 8 #include "net/base/net_errors.h" | 8 #include "net/base/net_errors.h" |
| 9 #include "net/quic/crypto/crypto_protocol.h" | 9 #include "net/quic/crypto/crypto_protocol.h" |
| 10 #include "net/quic/crypto/crypto_utils.h" | 10 #include "net/quic/crypto/crypto_utils.h" |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 return OK; | 421 return OK; |
| 422 } | 422 } |
| 423 | 423 |
| 424 generation_counter_ = cached->generation_counter(); | 424 generation_counter_ = cached->generation_counter(); |
| 425 next_state_ = STATE_LOAD_QUIC_SERVER_INFO_COMPLETE; | 425 next_state_ = STATE_LOAD_QUIC_SERVER_INFO_COMPLETE; |
| 426 | 426 |
| 427 // TODO(rtenneti): If multiple tabs load the same URL, all requests except for | 427 // TODO(rtenneti): If multiple tabs load the same URL, all requests except for |
| 428 // the first request send InchoateClientHello. Fix the code to handle multiple | 428 // the first request send InchoateClientHello. Fix the code to handle multiple |
| 429 // requests. A possible solution is to wait for the first request to finish | 429 // requests. A possible solution is to wait for the first request to finish |
| 430 // and use the data from the disk cache for all requests. | 430 // and use the data from the disk cache for all requests. |
| 431 // quic_server_info->Persist requires quic_server_info to be ready. We might | 431 // We may need to call quic_server_info->Persist later. |
| 432 // have already initialized |cached| config from a the cached state for a | 432 // quic_server_info->Persist requires quic_server_info to be ready, so we |
| 433 // canonical hostname. | 433 // always call WaitForDataReady, even though we might have initialized |
| 434 // |cached| config from the cached state for a canonical hostname. |
| 434 int rv = quic_server_info->WaitForDataReady( | 435 int rv = quic_server_info->WaitForDataReady( |
| 435 base::Bind(&QuicCryptoClientStream::OnIOComplete, | 436 base::Bind(&QuicCryptoClientStream::OnIOComplete, |
| 436 base::Unretained(this))); | 437 base::Unretained(this))); |
| 437 | 438 |
| 438 if (rv != ERR_IO_PENDING) { | 439 if (rv != ERR_IO_PENDING) { |
| 439 disk_cache_load_result_ = rv; | 440 disk_cache_load_result_ = rv; |
| 440 } | 441 } |
| 441 return rv; | 442 return rv; |
| 442 } | 443 } |
| 443 | 444 |
| 444 void QuicCryptoClientStream::DoLoadQuicServerInfoComplete( | 445 void QuicCryptoClientStream::DoLoadQuicServerInfoComplete( |
| 445 QuicCryptoClientConfig::CachedState* cached) { | 446 QuicCryptoClientConfig::CachedState* cached) { |
| 446 next_state_ = STATE_SEND_CHLO; | 447 next_state_ = STATE_SEND_CHLO; |
| 447 | 448 |
| 448 // If someone else already saved a server config, we don't want to overwrite | 449 // If someone else already saved a server config, we don't want to overwrite |
| 449 // it. Also, if someone else saved a server config and then cleared it (so | 450 // it. Also, if someone else saved a server config and then cleared it (so |
| 450 // cached->IsEmpty() is true, but the generation counter changed), we still | 451 // cached->IsEmpty() is true), we still want to load from QuicServerInfo. |
| 451 // want to load from QuicServerInfo. | |
| 452 if (!cached->IsEmpty()) { | 452 if (!cached->IsEmpty()) { |
| 453 // Someone else has already saved a server config received from the network | |
| 454 // or the canonical server config. | |
| 455 return; | 453 return; |
| 456 } | 454 } |
| 457 | 455 |
| 458 if (disk_cache_load_result_ != OK || !cached->LoadQuicServerInfo( | 456 if (disk_cache_load_result_ != OK || !cached->LoadQuicServerInfo( |
| 459 session()->connection()->clock()->WallNow())) { | 457 session()->connection()->clock()->WallNow())) { |
| 460 // It is ok to proceed to STATE_SEND_CHLO when we cannot load QuicServerInfo | 458 // It is ok to proceed to STATE_SEND_CHLO when we cannot load QuicServerInfo |
| 461 // from the disk cache. | 459 // from the disk cache. |
| 462 DCHECK(cached->IsEmpty()); | 460 DCHECK(cached->IsEmpty()); |
| 463 DVLOG(1) << "Empty server_config"; | 461 DVLOG(1) << "Empty server_config"; |
| 464 return; | 462 return; |
| 465 } | 463 } |
| 466 | 464 |
| 467 ProofVerifier* verifier = crypto_config_->proof_verifier(); | 465 ProofVerifier* verifier = crypto_config_->proof_verifier(); |
| 468 if (!verifier) { | 466 if (!verifier) { |
| 469 // If no verifier is set then we don't check the certificates. | 467 // If no verifier is set then we don't check the certificates. |
| 470 cached->SetProofValid(); | 468 cached->SetProofValid(); |
| 471 } else if (!cached->signature().empty()) { | 469 } else if (!cached->signature().empty()) { |
| 472 next_state_ = STATE_VERIFY_PROOF; | 470 next_state_ = STATE_VERIFY_PROOF; |
| 473 } | 471 } |
| 474 } | 472 } |
| 475 | 473 |
| 476 } // namespace net | 474 } // namespace net |
| OLD | NEW |