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

Unified Diff: net/quic/quic_crypto_client_stream.cc

Issue 154933003: Persist server's crypto config data to disk cache for 0-RTT (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Deleted unused data_loaded_ member Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: net/quic/quic_crypto_client_stream.cc
diff --git a/net/quic/quic_crypto_client_stream.cc b/net/quic/quic_crypto_client_stream.cc
index 3e5f84059fc0ec4567c39d1da66a18f7c3f5299c..bce6496a1679cfbcfdec6d3e8834b356f1d12f29 100644
--- a/net/quic/quic_crypto_client_stream.cc
+++ b/net/quic/quic_crypto_client_stream.cc
@@ -11,6 +11,7 @@
#include "net/quic/crypto/null_encrypter.h"
#include "net/quic/crypto/proof_verifier.h"
#include "net/quic/crypto/proof_verifier_chromium.h"
+#include "net/quic/crypto/quic_server_info.h"
#include "net/quic/quic_protocol.h"
#include "net/quic/quic_session.h"
#include "net/ssl/ssl_connection_status_flags.h"
@@ -91,7 +92,7 @@ void QuicCryptoClientStream::OnHandshakeMessage(
}
bool QuicCryptoClientStream::CryptoConnect() {
- next_state_ = STATE_SEND_CHLO;
+ next_state_ = STATE_LOAD_QUIC_SERVER_INFO;
DoHandshakeLoop(NULL);
return true;
}
@@ -159,6 +160,17 @@ void QuicCryptoClientStream::DoHandshakeLoop(
const State state = next_state_;
next_state_ = STATE_IDLE;
switch (state) {
+ case STATE_LOAD_QUIC_SERVER_INFO: {
+ if (DoLoadQuicServerInfo(cached) == ERR_IO_PENDING) {
+ return;
+ }
+ break;
+ }
+ case STATE_LOAD_QUIC_SERVER_INFO_COMPLETE: {
+ DoLoadQuicServerInfoComplete(cached);
+ DCHECK_EQ(STATE_SEND_CHLO, next_state_);
+ break;
+ }
case STATE_SEND_CHLO: {
// Send the client hello in plaintext.
session()->connection()->SetDefaultEncryptionLevel(ENCRYPTION_NONE);
@@ -166,6 +178,16 @@ void QuicCryptoClientStream::DoHandshakeLoop(
CloseConnection(QUIC_CRYPTO_TOO_MANY_REJECTS);
return;
}
+ if (!cached->proof_valid()) {
+ ProofVerifier* verifier = crypto_config_->proof_verifier();
+ if (!verifier) {
+ // If no verifier is set then we don't check the certificates.
+ cached->SetProofValid();
+ } else if (!cached->signature().empty()) {
+ next_state_ = STATE_VERIFY_PROOF;
+ break;
+ }
+ }
wtc 2014/02/11 01:01:45 I think this (lines 181-190) should be moved to Do
ramant (doing other things) 2014/02/11 07:57:55 Done.
num_client_hellos_++;
if (!cached->IsComplete(session()->connection()->clock()->WallNow())) {
@@ -318,6 +340,7 @@ void QuicCryptoClientStream::DoHandshakeLoop(
} else {
cached->SetProofValid();
cached->SetProofVerifyDetails(verify_details_.release());
+ cached->SaveQuicServerInfo();
wtc 2014/02/11 01:01:45 We should also call cached->SaveQuicServerInfo() w
ramant (doing other things) 2014/02/11 07:57:55 Done.
next_state_ = STATE_SEND_CHLO;
}
break;
@@ -394,4 +417,59 @@ void QuicCryptoClientStream::DoHandshakeLoop(
}
}
+void QuicCryptoClientStream::OnIOComplete(int result) {
+ DCHECK_EQ(STATE_LOAD_QUIC_SERVER_INFO, next_state_);
wtc 2014/02/11 01:01:45 next_state_ should be STATE_LOAD_QUIC_SERVER_INFO_
ramant (doing other things) 2014/02/11 07:57:55 Done.
+ DCHECK_NE(ERR_IO_PENDING, result);
+ if (result != OK) {
+ next_state_ = STATE_SEND_CHLO;
+ } else {
+ next_state_ = STATE_LOAD_QUIC_SERVER_INFO_COMPLETE;
+ }
wtc 2014/02/11 01:01:45 Lines 423-427 should be deleted. Since DoHandshak
ramant (doing other things) 2014/02/11 07:57:55 Done.
+ DoHandshakeLoop(NULL);
+}
+
+int QuicCryptoClientStream::DoLoadQuicServerInfo(
+ QuicCryptoClientConfig::CachedState* cached) {
+ next_state_ = STATE_SEND_CHLO;
+ QuicServerInfo* quic_server_info = cached->quic_server_info();
+ if (!quic_server_info) {
+ return OK;
+ }
+
+ // TODO(rtenneti): If multiple tabs load the same URL, all requests except for
+ // the first request send InchoateClientHello. Fix the code to handle multiple
+ // requests. A possible solution is to wait for the first request to finish
+ // and use the data from the disk cache for all requests.
+ int rv = quic_server_info->WaitForDataReady(
wtc 2014/02/11 01:01:45 We probably should save the generation count of |c
ramant (doing other things) 2014/02/11 07:57:55 Done.
+ base::Bind(&QuicCryptoClientStream::OnIOComplete,
+ base::Unretained(this)));
+
+ if (rv != OK) {
+ if (rv == ERR_IO_PENDING) {
+ next_state_ = STATE_LOAD_QUIC_SERVER_INFO;
wtc 2014/02/11 01:01:45 This should be STATE_LOAD_QUIC_SERVER_INFO_COMPLET
ramant (doing other things) 2014/02/11 07:57:55 Done.
+ return rv;
+ }
+ // It is ok to proceed to STATE_SEND_CHLO when we cannot load QuicServerInfo
+ // from the disk cache.
+ DVLOG(1) << "QuicServerInfo's WaitForDataReady failed";
+ }
+ return OK;
+}
+
+void QuicCryptoClientStream::DoLoadQuicServerInfoComplete(
+ QuicCryptoClientConfig::CachedState* cached) {
+ next_state_ = STATE_SEND_CHLO;
+
+ if (!cached->quic_server_info()->IsDataReady()) {
wtc 2014/02/11 01:01:45 We probably need to check the generation count her
ramant (doing other things) 2014/02/11 07:57:55 Done.
+ // It is ok to proceed to STATE_SEND_CHLO when we cannot load QuicServerInfo
+ // from the disk cache.
+ DVLOG(1) << "Loading of QuicServerInfo failed";
+ return;
+ }
+
+ cached->LoadQuicServerInfo();
+
+ return;
+}
+
} // namespace net
« net/quic/crypto/quic_server_info.cc ('K') | « net/quic/quic_crypto_client_stream.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698