diff options
-rw-r--r-- | chrome/browser/browsing_data/browsing_data_remover.cc | 7 | ||||
-rw-r--r-- | net/quic/crypto/quic_crypto_client_config.cc | 9 | ||||
-rw-r--r-- | net/quic/crypto/quic_crypto_client_config.h | 3 | ||||
-rw-r--r-- | net/quic/crypto/quic_crypto_client_config_test.cc | 42 | ||||
-rw-r--r-- | net/quic/quic_stream_factory.cc | 4 | ||||
-rw-r--r-- | net/quic/quic_stream_factory.h | 3 |
6 files changed, 67 insertions, 1 deletions
diff --git a/chrome/browser/browsing_data/browsing_data_remover.cc b/chrome/browser/browsing_data/browsing_data_remover.cc index ab7a6d7..1e39f58 100644 --- a/chrome/browser/browsing_data/browsing_data_remover.cc +++ b/chrome/browser/browsing_data/browsing_data_remover.cc @@ -902,9 +902,14 @@ void BrowsingDataRemover::DoClearCache(int rv) { net::HttpTransactionFactory* factory = getter->GetURLRequestContext()->http_transaction_factory(); + // Clear QUIC server information from memory. + net::HttpCache* http_cache = factory->GetCache(); + http_cache->GetSession()->quic_stream_factory()->ClearCachedStates(); + next_cache_state_ = (next_cache_state_ == STATE_CREATE_MAIN) ? STATE_DELETE_MAIN : STATE_DELETE_MEDIA; - rv = factory->GetCache()->GetBackend( + + rv = http_cache->GetBackend( &cache_, base::Bind(&BrowsingDataRemover::DoClearCache, base::Unretained(this))); break; 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 |