summaryrefslogtreecommitdiffstats
path: root/net/quic
diff options
context:
space:
mode:
authorrtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-21 22:17:57 +0000
committerrtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-21 22:17:57 +0000
commitf7e21a433cfbc472a968fea14dd3f3e99cb95d79 (patch)
tree3ed9aea101cd11a5b798bc2e1407a884b16056f6 /net/quic
parent47a285ec374c9564bbe171f84d8beb5b5f724cdd (diff)
downloadchromium_src-f7e21a433cfbc472a968fea14dd3f3e99cb95d79.zip
chromium_src-f7e21a433cfbc472a968fea14dd3f3e99cb95d79.tar.gz
chromium_src-f7e21a433cfbc472a968fea14dd3f3e99cb95d79.tar.bz2
QUIC - Delete the cached QUIC server information from memory whenever
disk cache is cleared. Bug: We were only deleting the disk cache's QUIC server information, but we weren't deleting the cached memory. TODO: delete both disk cache and memory cache whenever http_server_properties are cleared (or whenever any browser data is cleared). R=rch@chromium.org, michaeln@chromium.org Review URL: https://codereview.chromium.org/243013008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@265092 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/quic')
-rw-r--r--net/quic/crypto/quic_crypto_client_config.cc9
-rw-r--r--net/quic/crypto/quic_crypto_client_config.h3
-rw-r--r--net/quic/crypto/quic_crypto_client_config_test.cc42
-rw-r--r--net/quic/quic_stream_factory.cc4
-rw-r--r--net/quic/quic_stream_factory.h3
5 files changed, 61 insertions, 0 deletions
diff --git a/net/quic/crypto/quic_crypto_client_config.cc b/net/quic/crypto/quic_crypto_client_config.cc
index a614e6b..a6005bf 100644
--- a/net/quic/crypto/quic_crypto_client_config.cc
+++ b/net/quic/crypto/quic_crypto_client_config.cc
@@ -271,6 +271,15 @@ QuicCryptoClientConfig::CachedState* QuicCryptoClientConfig::LookupOrCreate(
return cached;
}
+void QuicCryptoClientConfig::ClearCachedStates() {
+ for (CachedStateMap::const_iterator it = cached_states_.begin();
+ it != cached_states_.end(); ++it) {
+ CachedState* cached = it->second;
+ cached->ClearProof();
+ cached->InvalidateServerConfig();
+ }
+}
+
void QuicCryptoClientConfig::FillInchoateClientHello(
const QuicServerId& server_id,
const QuicVersion preferred_version,
diff --git a/net/quic/crypto/quic_crypto_client_config.h b/net/quic/crypto/quic_crypto_client_config.h
index f88dcdf..8ed33fe 100644
--- a/net/quic/crypto/quic_crypto_client_config.h
+++ b/net/quic/crypto/quic_crypto_client_config.h
@@ -136,6 +136,9 @@ class NET_EXPORT_PRIVATE QuicCryptoClientConfig : public QuicCryptoConfig {
// CachedState currently exists, it will be created and cached.
CachedState* LookupOrCreate(const QuicServerId& server_id);
+ // Delete all CachedState objects from cached_states_.
+ void ClearCachedStates();
+
// FillInchoateClientHello sets |out| to be a CHLO message that elicits a
// source-address token or SCFG from a server. If |cached| is non-NULL, the
// source-address token will be taken from it. |out_params| is used in order
diff --git a/net/quic/crypto/quic_crypto_client_config_test.cc b/net/quic/crypto/quic_crypto_client_config_test.cc
index c435810..16e14dd 100644
--- a/net/quic/crypto/quic_crypto_client_config_test.cc
+++ b/net/quic/crypto/quic_crypto_client_config_test.cc
@@ -11,6 +11,7 @@
#include "testing/gtest/include/gtest/gtest.h"
using std::string;
+using std::vector;
namespace net {
namespace test {
@@ -226,5 +227,46 @@ TEST(QuicCryptoClientConfigTest, CanonicalNotUsedIfNotValid) {
EXPECT_TRUE(config.LookupOrCreate(canonical_id2)->IsEmpty());
}
+TEST(QuicCryptoClientConfigTest, ClearCachedStates) {
+ QuicCryptoClientConfig config;
+ QuicServerId canonical_server_id("www.google.com", 80, false,
+ PRIVACY_MODE_DISABLED);
+ QuicCryptoClientConfig::CachedState* state =
+ config.LookupOrCreate(canonical_server_id);
+ // TODO(rch): Populate other fields of |state|.
+ vector<string> certs(1);
+ certs[0] = "Hello Cert";
+ state->SetProof(certs, "signature");
+ state->set_source_address_token("TOKEN");
+ state->SetProofValid();
+
+ // Verify LookupOrCreate returns the same data.
+ QuicServerId other_server_id("www.google.com", 80, false,
+ PRIVACY_MODE_DISABLED);
+
+ QuicCryptoClientConfig::CachedState* other =
+ config.LookupOrCreate(other_server_id);
+
+ EXPECT_TRUE(other->proof_valid());
+ EXPECT_EQ(state->server_config(), other->server_config());
+ EXPECT_EQ(state->signature(), other->signature());
+ EXPECT_EQ(state->certs(), other->certs());
+ EXPECT_EQ(state->source_address_token(), other->source_address_token());
+ EXPECT_EQ(1u, other->generation_counter());
+
+ // Clear the cached state.
+ config.ClearCachedStates();
+
+ // Verify LookupOrCreate doesn't have any data.
+ QuicCryptoClientConfig::CachedState* cleared_cache =
+ config.LookupOrCreate(other_server_id);
+
+ EXPECT_FALSE(cleared_cache->proof_valid());
+ EXPECT_TRUE(cleared_cache->server_config().empty());
+ EXPECT_TRUE(cleared_cache->certs().empty());
+ EXPECT_TRUE(cleared_cache->signature().empty());
+ EXPECT_LT(1u, cleared_cache->generation_counter());
+}
+
} // namespace test
} // namespace net
diff --git a/net/quic/quic_stream_factory.cc b/net/quic/quic_stream_factory.cc
index abb60a28..32828b8 100644
--- a/net/quic/quic_stream_factory.cc
+++ b/net/quic/quic_stream_factory.cc
@@ -648,6 +648,10 @@ base::Value* QuicStreamFactory::QuicStreamFactoryInfoToValue() const {
return list;
}
+void QuicStreamFactory::ClearCachedStates() {
+ crypto_config_.ClearCachedStates();
+}
+
void QuicStreamFactory::OnIPAddressChanged() {
CloseAllSessions(ERR_NETWORK_CHANGED);
require_confirmation_ = true;
diff --git a/net/quic/quic_stream_factory.h b/net/quic/quic_stream_factory.h
index 490e2f9..f55cfbd 100644
--- a/net/quic/quic_stream_factory.h
+++ b/net/quic/quic_stream_factory.h
@@ -132,6 +132,9 @@ class NET_EXPORT_PRIVATE QuicStreamFactory
base::Value* QuicStreamFactoryInfoToValue() const;
+ // Delete all cached state objects in |crypto_config_|.
+ void ClearCachedStates();
+
// NetworkChangeNotifier::IPAddressObserver methods:
// Until the servers support roaming, close all connections when the local