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

Unified Diff: net/quic/crypto/quic_crypto_client_config.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: Fix comments for Patch Set 4 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/crypto/quic_crypto_client_config.cc
diff --git a/net/quic/crypto/quic_crypto_client_config.cc b/net/quic/crypto/quic_crypto_client_config.cc
index 876391065330cd78b1259d34c45a63a7994ee870..c1485919be7b458069b2b2495dbac338fb8e6442 100644
--- a/net/quic/crypto/quic_crypto_client_config.cc
+++ b/net/quic/crypto/quic_crypto_client_config.cc
@@ -38,11 +38,13 @@ QuicCryptoClientConfig::~QuicCryptoClientConfig() {
QuicCryptoClientConfig::CachedState::CachedState()
: server_config_valid_(false),
+ need_to_persist_(false),
generation_counter_(0) {}
QuicCryptoClientConfig::CachedState::CachedState(
scoped_ptr<QuicServerInfo> quic_server_info)
: server_config_valid_(false),
+ need_to_persist_(false),
generation_counter_(0),
quic_server_info_(quic_server_info.Pass()) {}
@@ -118,6 +120,7 @@ QuicErrorCode QuicCryptoClientConfig::CachedState::SetServerConfig(
server_config_ = server_config.as_string();
SetProofInvalid();
scfg_.reset(new_scfg_storage.release());
+ need_to_persist_ = true;
}
return QUIC_NO_ERROR;
}
@@ -160,6 +163,7 @@ void QuicCryptoClientConfig::CachedState::ClearProof() {
void QuicCryptoClientConfig::CachedState::SetProofValid() {
server_config_valid_ = true;
+ SaveQuicServerInfo();
}
void QuicCryptoClientConfig::CachedState::SetProofInvalid() {
@@ -197,6 +201,10 @@ QuicCryptoClientConfig::CachedState::proof_verify_details() const {
return proof_verify_details_.get();
}
+QuicServerInfo* QuicCryptoClientConfig::CachedState::quic_server_info() const {
+ return quic_server_info_.get();
+}
+
void QuicCryptoClientConfig::CachedState::set_source_address_token(
StringPiece token) {
source_address_token_ = token.as_string();
@@ -218,6 +226,55 @@ void QuicCryptoClientConfig::CachedState::InitializeFrom(
server_config_valid_ = other.server_config_valid_;
}
+// TODO(rtenneti): LoadQuicServerInfo and SaveQuicServerInfo have duplication of
+// data in CachedState and QuicServerInfo. We should eliminate the duplication
+// of data.
+// An issue to be solved: while we are loading the data from disk cache, it is
+// possible for another request for the same hostname update the CachedState
+// because that request has sent FillInchoateClientHello and got REJ message.
+// Loading of data from disk cache shouldn't blindly overwrite what is in
+// CachedState.
+void QuicCryptoClientConfig::CachedState::LoadQuicServerInfo() {
wtc 2014/02/14 01:46:13 This method needs to return a bool status.
ramant (doing other things) 2014/02/15 00:36:12 Done.
+ if (!server_config_.empty()) {
wtc 2014/02/14 01:46:13 This should become a DCHECK: DCHECK(server_confi
ramant (doing other things) 2014/02/15 00:36:12 Done.
+ return;
+ }
+ DCHECK(quic_server_info_.get());
+
+ const QuicServerInfo::State& state(quic_server_info_->state());
+ if (state.server_config.empty()) {
+ return;
wtc 2014/02/14 01:46:13 We should return false.
ramant (doing other things) 2014/02/15 00:36:12 Done.
+ }
+
+ server_config_ = state.server_config;
wtc 2014/02/13 23:48:43 I now think we should call SetServerConfig() to se
wtc 2014/02/14 01:46:13 If SetServerConfig() fails, we should return false
ramant (doing other things) 2014/02/15 00:36:12 Done.
ramant (doing other things) 2014/02/15 00:36:12 Done.
+ source_address_token_ = state.source_address_token;
+ server_config_sig_ = state.server_config_sig;
+ certs_ = state.certs;
+ need_to_persist_ = false;
+}
+
+void QuicCryptoClientConfig::CachedState::SaveQuicServerInfo() {
+ if (!quic_server_info_.get() || !need_to_persist_) {
+ return;
+ }
+ DCHECK(server_config_valid_);
+
+ // If the QuicServerInfo hasn't managed to load from disk yet then we can't
+ // save anything.
+ if (!quic_server_info_->IsDataReady()) {
+ return;
+ }
+
+ QuicServerInfo::State* state = quic_server_info_->mutable_state();
+
+ state->server_config = server_config_;
+ state->source_address_token = source_address_token_;
+ state->server_config_sig = server_config_sig_;
+ state->certs = certs_;
+
+ quic_server_info_->Persist();
+ need_to_persist_ = false;
+}
+
void QuicCryptoClientConfig::SetDefaults() {
// Key exchange methods.
kexs.resize(2);

Powered by Google App Engine
This is Rietveld 408576698