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

Unified Diff: net/quic/quic_crypto_client_stream.cc

Issue 196403002: Move QuicServerInfo management from CachedState to the QuicStreamFactory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 9e48e4f5611ac7ce14b654351298cc077531bd4f..bd06a02eeb06b1848fa7649b1836559d4be4ff5b 100644
--- a/net/quic/quic_crypto_client_stream.cc
+++ b/net/quic/quic_crypto_client_stream.cc
@@ -13,6 +13,7 @@
#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/crypto/quic_server_info.h"
ramant (doing other things) 2014/03/12 00:50:56 nit: line 16 could be deleted.
Ryan Hamilton 2014/03/12 04:00:45 Done.
#include "net/quic/quic_protocol.h"
#include "net/quic/quic_session.h"
#include "net/ssl/ssl_connection_status_flags.h"
@@ -65,7 +66,6 @@ void QuicCryptoClientStream::ProofVerifierCallbackImpl::Cancel() {
stream_ = NULL;
}
-
QuicCryptoClientStream::QuicCryptoClientStream(
const string& server_hostname,
QuicSession* session,
@@ -415,11 +415,15 @@ void QuicCryptoClientStream::OnIOComplete(int result) {
DoHandshakeLoop(NULL);
}
+void QuicCryptoClientStream::SetQuicServerInfo(
+ scoped_ptr<QuicServerInfo> server_info) {
+ quic_server_info_.reset(server_info.release());
+}
+
int QuicCryptoClientStream::DoLoadQuicServerInfo(
QuicCryptoClientConfig::CachedState* cached) {
next_state_ = STATE_SEND_CHLO;
- QuicServerInfo* quic_server_info = cached->quic_server_info();
- if (!quic_server_info) {
+ if (!quic_server_info_) {
return OK;
}
@@ -437,7 +441,7 @@ int QuicCryptoClientStream::DoLoadQuicServerInfo(
// quic_server_info->Persist requires quic_server_info to be ready, so we
// always call WaitForDataReady, even though we might have initialized
// |cached| config from the cached state for a canonical hostname.
- int rv = quic_server_info->WaitForDataReady(
+ int rv = quic_server_info_->WaitForDataReady(
base::Bind(&QuicCryptoClientStream::OnIOComplete,
weak_factory_.GetWeakPtr()));
@@ -450,7 +454,7 @@ int QuicCryptoClientStream::DoLoadQuicServerInfo(
void QuicCryptoClientStream::DoLoadQuicServerInfoComplete(
QuicCryptoClientConfig::CachedState* cached) {
LoadQuicServerInfo(cached);
- QuicServerInfo::State* state = cached->quic_server_info()->mutable_state();
+ QuicServerInfo::State* state = quic_server_info_->mutable_state();
state->Clear();
}
@@ -468,8 +472,12 @@ void QuicCryptoClientStream::LoadQuicServerInfo(
UMA_HISTOGRAM_TIMES("Net.QuicServerInfo.DiskCacheReadTime",
base::TimeTicks::Now() - read_start_time_);
- if (disk_cache_load_result_ != OK || !cached->LoadQuicServerInfo(
- session()->connection()->clock()->WallNow())) {
+ if (disk_cache_load_result_ != OK ||
+ !cached->Initialize(quic_server_info_->state().server_config,
+ quic_server_info_->state().server_config_sig,
+ quic_server_info_->state().source_address_token,
+ quic_server_info_->state().certs,
+ session()->connection()->clock()->WallNow())) {
// It is ok to proceed to STATE_SEND_CHLO when we cannot load QuicServerInfo
// from the disk cache.
DCHECK(cached->IsEmpty());
@@ -486,4 +494,24 @@ void QuicCryptoClientStream::LoadQuicServerInfo(
}
}
+void QuicCryptoClientStream::SaveQuicServerInfo(
+ QuicCryptoClientConfig::CachedState* cached) {
+ DCHECK(cached->proof_valid());
+
+ // If the QuicServerInfo hasn't managed to load from disk yet then we can't
+ // save anything. TODO(rtenneti): we should fix this.
+ if (!quic_server_info_->IsDataReady()) {
+ return;
+ }
+
+ QuicServerInfo::State* state = quic_server_info_->mutable_state();
+
+ state->server_config = cached->server_config();
+ state->source_address_token = cached->source_address_token();
+ state->server_config_sig = cached->signature();
+ state->certs = cached->certs();
+
+ quic_server_info_->Persist();
+}
+
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698