summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/quic/crypto/quic_crypto_client_config.cc48
-rw-r--r--net/quic/crypto/quic_crypto_client_config.h19
-rw-r--r--net/quic/quic_stream_factory.cc14
3 files changed, 48 insertions, 33 deletions
diff --git a/net/quic/crypto/quic_crypto_client_config.cc b/net/quic/crypto/quic_crypto_client_config.cc
index 84dfee0..8763910 100644
--- a/net/quic/crypto/quic_crypto_client_config.cc
+++ b/net/quic/crypto/quic_crypto_client_config.cc
@@ -29,13 +29,7 @@ using std::vector;
namespace net {
-QuicCryptoClientConfig::QuicCryptoClientConfig()
- : quic_server_info_factory_(NULL) {
-}
-
-QuicCryptoClientConfig::QuicCryptoClientConfig(
- QuicServerInfoFactory* quic_server_info_factory)
- : quic_server_info_factory_(quic_server_info_factory) {
+QuicCryptoClientConfig::QuicCryptoClientConfig() {
}
QuicCryptoClientConfig::~QuicCryptoClientConfig() {
@@ -46,17 +40,13 @@ QuicCryptoClientConfig::CachedState::CachedState()
: server_config_valid_(false),
generation_counter_(0) {}
-QuicCryptoClientConfig::CachedState::~CachedState() {}
-
-void QuicCryptoClientConfig::CachedState::LoadFromDiskCache(
- QuicServerInfoFactory* quic_server_info_factory,
- const string& server_hostname) {
- DCHECK(quic_server_info_factory);
- quic_server_info_.reset(
- quic_server_info_factory->GetForHost(server_hostname));
+QuicCryptoClientConfig::CachedState::CachedState(
+ scoped_ptr<QuicServerInfo> quic_server_info)
+ : server_config_valid_(false),
+ generation_counter_(0),
+ quic_server_info_(quic_server_info.Pass()) {}
- // TODO(rtenneti): Need to flesh out reading data from disk cache.
-}
+QuicCryptoClientConfig::CachedState::~CachedState() {}
bool QuicCryptoClientConfig::CachedState::IsComplete(QuicWallTime now) const {
if (server_config_.empty() || !server_config_valid_) {
@@ -239,6 +229,22 @@ void QuicCryptoClientConfig::SetDefaults() {
aead[0] = kAESG;
}
+QuicCryptoClientConfig::CachedState* QuicCryptoClientConfig::Create(
+ const string& server_hostname,
+ QuicServerInfoFactory* quic_server_info_factory) {
+ DCHECK(cached_states_.find(server_hostname) == cached_states_.end());
+ scoped_ptr<QuicServerInfo> quic_server_info;
+ if (quic_server_info_factory) {
+ quic_server_info.reset(
+ quic_server_info_factory->GetForHost(server_hostname));
+ quic_server_info->Start();
+ }
+
+ CachedState* cached = new CachedState(quic_server_info.Pass());
+ cached_states_.insert(make_pair(server_hostname, cached));
+ return cached;
+}
+
QuicCryptoClientConfig::CachedState* QuicCryptoClientConfig::LookupOrCreate(
const string& server_hostname) {
map<string, CachedState*>::const_iterator it =
@@ -246,13 +252,7 @@ QuicCryptoClientConfig::CachedState* QuicCryptoClientConfig::LookupOrCreate(
if (it != cached_states_.end()) {
return it->second;
}
-
- CachedState* cached = new CachedState;
- if (quic_server_info_factory_) {
- cached->LoadFromDiskCache(quic_server_info_factory_, server_hostname);
- }
- cached_states_.insert(make_pair(server_hostname, cached));
- return cached;
+ return Create(server_hostname, NULL);
}
void QuicCryptoClientConfig::FillInchoateClientHello(
diff --git a/net/quic/crypto/quic_crypto_client_config.h b/net/quic/crypto/quic_crypto_client_config.h
index 30b5196d..b11c197fa 100644
--- a/net/quic/crypto/quic_crypto_client_config.h
+++ b/net/quic/crypto/quic_crypto_client_config.h
@@ -36,6 +36,7 @@ class NET_EXPORT_PRIVATE QuicCryptoClientConfig : public QuicCryptoConfig {
class NET_EXPORT_PRIVATE CachedState {
public:
CachedState();
+ explicit CachedState(scoped_ptr<QuicServerInfo> quic_server_info);
~CachedState();
// IsComplete returns true if this object contains enough information to
@@ -94,11 +95,6 @@ class NET_EXPORT_PRIVATE QuicCryptoClientConfig : public QuicCryptoConfig {
// unchanged.
void InitializeFrom(const CachedState& other);
- // TODO(rtenneti): Need to flesh out the details of this method. A temporary
- // place holder to load CachedState from disk cache.
- void LoadFromDiskCache(QuicServerInfoFactory* quic_server_info_factory,
- const std::string& server_hostname);
-
private:
std::string server_config_id_; // An opaque id from the server.
std::string server_config_; // A serialized handshake message.
@@ -119,21 +115,29 @@ class NET_EXPORT_PRIVATE QuicCryptoClientConfig : public QuicCryptoConfig {
// scfg contains the cached, parsed value of |server_config|.
mutable scoped_ptr<CryptoHandshakeMessage> scfg_;
+ // |quic_server_info_| is used to fetch crypto config information from disk.
scoped_ptr<QuicServerInfo> quic_server_info_;
DISALLOW_COPY_AND_ASSIGN(CachedState);
};
QuicCryptoClientConfig();
- explicit QuicCryptoClientConfig(
- QuicServerInfoFactory* quic_server_info_factory);
~QuicCryptoClientConfig();
// Sets the members to reasonable, default values.
void SetDefaults();
+ // Create returns a CachedState for the given hostname. It creates a
+ // CachedState and caches it. If |quic_server_info_factory| is not NULL, then
+ // it is used to create QuicServerInfo which is used to fetch crypto config
+ // information from disk for the given hostname.
+ CachedState* Create(const std::string& server_hostname,
+ QuicServerInfoFactory* quic_server_info_factory);
+
// LookupOrCreate returns a CachedState for the given hostname. If no such
// CachedState currently exists, it will be created and cached.
+ // TODO(rtenneti): fix the server code and pass QuicServerInfoFactory as
+ // argument.
CachedState* LookupOrCreate(const std::string& server_hostname);
// FillInchoateClientHello sets |out| to be a CHLO message that elicits a
@@ -224,7 +228,6 @@ class NET_EXPORT_PRIVATE QuicCryptoClientConfig : public QuicCryptoConfig {
// about that server.
std::map<std::string, CachedState*> cached_states_;
- QuicServerInfoFactory* quic_server_info_factory_;
scoped_ptr<ProofVerifier> proof_verifier_;
scoped_ptr<ChannelIDSigner> channel_id_signer_;
diff --git a/net/quic/quic_stream_factory.cc b/net/quic/quic_stream_factory.cc
index 27ce25d..51681ad 100644
--- a/net/quic/quic_stream_factory.cc
+++ b/net/quic/quic_stream_factory.cc
@@ -327,6 +327,12 @@ int QuicStreamFactory::Create(const HostPortProxyPair& host_port_proxy_pair,
return ERR_IO_PENDING;
}
+ // Create crypto config and start the process of loading QUIC server
+ // information from disk cache.
+ QuicCryptoClientConfig* crypto_config =
+ GetOrCreateCryptoConfig(host_port_proxy_pair);
+ DCHECK(crypto_config);
+
scoped_ptr<Job> job(new Job(this, host_resolver_, host_port_proxy_pair,
is_https, cert_verifier, net_log));
int rv = job->Run(base::Bind(&QuicStreamFactory::OnJobComplete,
@@ -627,7 +633,13 @@ QuicCryptoClientConfig* QuicStreamFactory::GetOrCreateCryptoConfig(
} else {
// TODO(rtenneti): if two quic_sessions for the same host_port_proxy_pair
// share the same crypto_config, will it cause issues?
- crypto_config = new QuicCryptoClientConfig(quic_server_info_factory_);
+ crypto_config = new QuicCryptoClientConfig();
+ if (quic_server_info_factory_) {
+ QuicCryptoClientConfig::CachedState* cached =
+ crypto_config->Create(host_port_proxy_pair.first.host(),
+ quic_server_info_factory_);
+ DCHECK(cached);
+ }
crypto_config->SetDefaults();
all_crypto_configs_[host_port_proxy_pair] = crypto_config;
PopulateFromCanonicalConfig(host_port_proxy_pair, crypto_config);