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_crypto_client_stream.h" | 5 #include "net/quic/quic_crypto_client_stream.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | |
| 7 #include "net/base/completion_callback.h" | 8 #include "net/base/completion_callback.h" |
| 8 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
| 9 #include "net/quic/crypto/crypto_protocol.h" | 10 #include "net/quic/crypto/crypto_protocol.h" |
| 10 #include "net/quic/crypto/crypto_utils.h" | 11 #include "net/quic/crypto/crypto_utils.h" |
| 11 #include "net/quic/crypto/null_encrypter.h" | 12 #include "net/quic/crypto/null_encrypter.h" |
| 12 #include "net/quic/crypto/proof_verifier.h" | 13 #include "net/quic/crypto/proof_verifier.h" |
| 13 #include "net/quic/crypto/proof_verifier_chromium.h" | 14 #include "net/quic/crypto/proof_verifier_chromium.h" |
| 14 #include "net/quic/crypto/quic_server_info.h" | 15 #include "net/quic/crypto/quic_server_info.h" |
| 15 #include "net/quic/quic_protocol.h" | 16 #include "net/quic/quic_protocol.h" |
| 16 #include "net/quic/quic_session.h" | 17 #include "net/quic/quic_session.h" |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 415 } | 416 } |
| 416 | 417 |
| 417 int QuicCryptoClientStream::DoLoadQuicServerInfo( | 418 int QuicCryptoClientStream::DoLoadQuicServerInfo( |
| 418 QuicCryptoClientConfig::CachedState* cached) { | 419 QuicCryptoClientConfig::CachedState* cached) { |
| 419 next_state_ = STATE_SEND_CHLO; | 420 next_state_ = STATE_SEND_CHLO; |
| 420 QuicServerInfo* quic_server_info = cached->quic_server_info(); | 421 QuicServerInfo* quic_server_info = cached->quic_server_info(); |
| 421 if (!quic_server_info) { | 422 if (!quic_server_info) { |
| 422 return OK; | 423 return OK; |
| 423 } | 424 } |
| 424 | 425 |
| 426 read_start_time_ = base::TimeTicks::Now(); | |
| 425 generation_counter_ = cached->generation_counter(); | 427 generation_counter_ = cached->generation_counter(); |
| 426 next_state_ = STATE_LOAD_QUIC_SERVER_INFO_COMPLETE; | 428 next_state_ = STATE_LOAD_QUIC_SERVER_INFO_COMPLETE; |
| 427 | 429 |
| 428 // TODO(rtenneti): If multiple tabs load the same URL, all requests except for | 430 // TODO(rtenneti): If multiple tabs load URLs with same hostname but different |
|
Ryan Hamilton
2014/03/07 22:24:43
Please add a TODO to use the host:port and not jus
ramant (doing other things)
2014/03/07 22:34:01
Done.
| |
| 429 // the first request send InchoateClientHello. Fix the code to handle multiple | 431 // ports, all requests except for the first request send InchoateClientHello. |
| 430 // requests. A possible solution is to wait for the first request to finish | 432 // Fix the code to handle multiple requests. A possible solution is to wait |
| 431 // and use the data from the disk cache for all requests. | 433 // for the first request to finish and use the data from the disk cache for |
| 434 // all requests. | |
| 432 // We may need to call quic_server_info->Persist later. | 435 // We may need to call quic_server_info->Persist later. |
| 433 // quic_server_info->Persist requires quic_server_info to be ready, so we | 436 // quic_server_info->Persist requires quic_server_info to be ready, so we |
| 434 // always call WaitForDataReady, even though we might have initialized | 437 // always call WaitForDataReady, even though we might have initialized |
| 435 // |cached| config from the cached state for a canonical hostname. | 438 // |cached| config from the cached state for a canonical hostname. |
| 436 int rv = quic_server_info->WaitForDataReady( | 439 int rv = quic_server_info->WaitForDataReady( |
| 437 base::Bind(&QuicCryptoClientStream::OnIOComplete, | 440 base::Bind(&QuicCryptoClientStream::OnIOComplete, |
| 438 weak_factory_.GetWeakPtr())); | 441 weak_factory_.GetWeakPtr())); |
| 439 | 442 |
| 440 if (rv != ERR_IO_PENDING) { | 443 if (rv != ERR_IO_PENDING) { |
| 441 disk_cache_load_result_ = rv; | 444 disk_cache_load_result_ = rv; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 454 QuicCryptoClientConfig::CachedState* cached) { | 457 QuicCryptoClientConfig::CachedState* cached) { |
| 455 next_state_ = STATE_SEND_CHLO; | 458 next_state_ = STATE_SEND_CHLO; |
| 456 | 459 |
| 457 // If someone else already saved a server config, we don't want to overwrite | 460 // If someone else already saved a server config, we don't want to overwrite |
| 458 // it. Also, if someone else saved a server config and then cleared it (so | 461 // it. Also, if someone else saved a server config and then cleared it (so |
| 459 // cached->IsEmpty() is true), we still want to load from QuicServerInfo. | 462 // cached->IsEmpty() is true), we still want to load from QuicServerInfo. |
| 460 if (!cached->IsEmpty()) { | 463 if (!cached->IsEmpty()) { |
| 461 return; | 464 return; |
| 462 } | 465 } |
| 463 | 466 |
| 467 UMA_HISTOGRAM_TIMES("Net.QuicServerInfo.DiskCacheReadTime", | |
| 468 base::TimeTicks::Now() - read_start_time_); | |
| 469 | |
| 464 if (disk_cache_load_result_ != OK || !cached->LoadQuicServerInfo( | 470 if (disk_cache_load_result_ != OK || !cached->LoadQuicServerInfo( |
| 465 session()->connection()->clock()->WallNow())) { | 471 session()->connection()->clock()->WallNow())) { |
| 466 // It is ok to proceed to STATE_SEND_CHLO when we cannot load QuicServerInfo | 472 // It is ok to proceed to STATE_SEND_CHLO when we cannot load QuicServerInfo |
| 467 // from the disk cache. | 473 // from the disk cache. |
| 468 DCHECK(cached->IsEmpty()); | 474 DCHECK(cached->IsEmpty()); |
| 469 DVLOG(1) << "Empty server_config"; | 475 DVLOG(1) << "Empty server_config"; |
| 470 return; | 476 return; |
| 471 } | 477 } |
| 472 | 478 |
| 473 ProofVerifier* verifier = crypto_config_->proof_verifier(); | 479 ProofVerifier* verifier = crypto_config_->proof_verifier(); |
| 474 if (!verifier) { | 480 if (!verifier) { |
| 475 // If no verifier is set then we don't check the certificates. | 481 // If no verifier is set then we don't check the certificates. |
| 476 cached->SetProofValid(); | 482 cached->SetProofValid(); |
| 477 } else if (!cached->signature().empty()) { | 483 } else if (!cached->signature().empty()) { |
| 478 next_state_ = STATE_VERIFY_PROOF; | 484 next_state_ = STATE_VERIFY_PROOF; |
| 479 } | 485 } |
| 480 } | 486 } |
| 481 | 487 |
| 482 } // namespace net | 488 } // namespace net |
| OLD | NEW |