diff options
author | rtenneti <rtenneti@chromium.org> | 2016-01-15 12:12:10 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-15 20:13:08 +0000 |
commit | 6971c17d82c972e7bd26eb2e463e89b1f4922047 (patch) | |
tree | fd07eb2498615c6adfe1f58862e73b44d6b6fbf9 | |
parent | b27b563bf2f716a7757eb90626b029cc16047847 (diff) | |
download | chromium_src-6971c17d82c972e7bd26eb2e463e89b1f4922047.zip chromium_src-6971c17d82c972e7bd26eb2e463e89b1f4922047.tar.gz chromium_src-6971c17d82c972e7bd26eb2e463e89b1f4922047.tar.bz2 |
QUIC - Allow cronet apps to specify how many server configs are to be
persisted in prefs file (local_prefs.json).
Added "max_server_configs_stored_in_properties" cronet
experiment options.
Will delete support for "store_server_configs_in_properties",
after all cronet apps stop using it. Added backward
compatibility code that sets
number_of_server_configs_stored_in_properties to 5
when this option is enabled.
R=rch@chromium.org, mef@chromium.org
Review URL: https://codereview.chromium.org/1572753003
Cr-Commit-Position: refs/heads/master@{#369825}
-rw-r--r-- | components/cronet/android/test/javatests/src/org/chromium/net/QuicTest.java | 2 | ||||
-rw-r--r-- | components/cronet/url_request_context_config.cc | 16 | ||||
-rw-r--r-- | components/cronet/url_request_context_config_unittest.cc | 6 | ||||
-rw-r--r-- | net/http/http_network_session.cc | 10 | ||||
-rw-r--r-- | net/http/http_network_session.h | 5 | ||||
-rw-r--r-- | net/http/http_server_properties.h | 7 | ||||
-rw-r--r-- | net/http/http_server_properties_impl.cc | 27 | ||||
-rw-r--r-- | net/http/http_server_properties_impl.h | 4 | ||||
-rw-r--r-- | net/http/http_server_properties_impl_unittest.cc | 21 | ||||
-rw-r--r-- | net/http/http_server_properties_manager.cc | 19 | ||||
-rw-r--r-- | net/http/http_server_properties_manager.h | 3 | ||||
-rw-r--r-- | net/http/http_server_properties_manager_unittest.cc | 23 | ||||
-rw-r--r-- | net/quic/quic_stream_factory.cc | 7 | ||||
-rw-r--r-- | net/quic/quic_stream_factory.h | 11 | ||||
-rw-r--r-- | net/quic/quic_stream_factory_test.cc | 9 | ||||
-rw-r--r-- | net/url_request/url_request_context_builder.cc | 6 | ||||
-rw-r--r-- | net/url_request/url_request_context_builder.h | 10 |
17 files changed, 144 insertions, 42 deletions
diff --git a/components/cronet/android/test/javatests/src/org/chromium/net/QuicTest.java b/components/cronet/android/test/javatests/src/org/chromium/net/QuicTest.java index 4854cb5..fa9c5d0 100644 --- a/components/cronet/android/test/javatests/src/org/chromium/net/QuicTest.java +++ b/components/cronet/android/test/javatests/src/org/chromium/net/QuicTest.java @@ -43,7 +43,7 @@ public class QuicTest extends CronetTestBase { JSONObject quicParams = new JSONObject() .put("connection_options", "PACE,IW10,FOO,DEADBEEF") .put("host_whitelist", "test.example.com") - .put("store_server_configs_in_properties", true) + .put("max_server_configs_stored_in_properties", 2) .put("delay_tcp_race", true) .put("max_number_of_lossy_connections", 10) .put("packet_loss_threshold", 0.5) diff --git a/components/cronet/url_request_context_config.cc b/components/cronet/url_request_context_config.cc index cb19efc..ca88279 100644 --- a/components/cronet/url_request_context_config.cc +++ b/components/cronet/url_request_context_config.cc @@ -15,6 +15,7 @@ #include "base/values.h" #include "net/cert/cert_verifier.h" #include "net/dns/host_resolver.h" +#include "net/http/http_server_properties.h" #include "net/quic/quic_protocol.h" #include "net/quic/quic_utils.h" #include "net/url_request/url_request_context_builder.h" @@ -28,6 +29,8 @@ const char kQuicFieldTrialName[] = "QUIC"; const char kQuicConnectionOptions[] = "connection_options"; const char kQuicStoreServerConfigsInProperties[] = "store_server_configs_in_properties"; +const char kQuicMaxServerConfigsStoredInProperties[] = + "max_server_configs_stored_in_properties"; const char kQuicDelayTcpRace[] = "delay_tcp_race"; const char kQuicMaxNumberOfLossyConnections[] = "max_number_of_lossy_connections"; @@ -76,11 +79,20 @@ void ParseAndSetExperimentalOptions( net::QuicUtils::ParseQuicConnectionOptions(quic_connection_options)); } + // TODO(rtenneti): Delete this option after apps stop using it. + // Added this for backward compatibility. bool quic_store_server_configs_in_properties = false; if (quic_args->GetBoolean(kQuicStoreServerConfigsInProperties, &quic_store_server_configs_in_properties)) { - context_builder->set_quic_store_server_configs_in_properties( - quic_store_server_configs_in_properties); + context_builder->set_quic_max_server_configs_stored_in_properties( + net::kMaxQuicServersToPersist); + } + + int quic_max_server_configs_stored_in_properties = 0; + if (quic_args->GetInteger(kQuicMaxServerConfigsStoredInProperties, + &quic_max_server_configs_stored_in_properties)) { + context_builder->set_quic_max_server_configs_stored_in_properties( + static_cast<size_t>(quic_max_server_configs_stored_in_properties)); } bool quic_delay_tcp_race = false; diff --git a/components/cronet/url_request_context_config_unittest.cc b/components/cronet/url_request_context_config_unittest.cc index e360f55..d14c32e 100644 --- a/components/cronet/url_request_context_config_unittest.cc +++ b/components/cronet/url_request_context_config_unittest.cc @@ -35,7 +35,7 @@ TEST(URLRequestContextConfigTest, SetQuicExperimentalOptions) { // User-Agent request header field. "fake agent", // JSON encoded experimental options. - "{\"QUIC\":{\"store_server_configs_in_properties\":true," + "{\"QUIC\":{\"max_server_configs_stored_in_properties\":2," "\"delay_tcp_race\":true," "\"max_number_of_lossy_connections\":10," "\"packet_loss_threshold\":0.5," @@ -69,8 +69,8 @@ TEST(URLRequestContextConfigTest, SetQuicExperimentalOptions) { quic_connection_options.push_back(net::kREJ); EXPECT_EQ(quic_connection_options, params->quic_connection_options); - // Check store_server_configs_in_properties. - EXPECT_TRUE(params->quic_store_server_configs_in_properties); + // Check max_server_configs_stored_in_properties. + EXPECT_EQ(2u, params->quic_max_server_configs_stored_in_properties); // Check delay_tcp_race. EXPECT_TRUE(params->quic_delay_tcp_race); diff --git a/net/http/http_network_session.cc b/net/http/http_network_session.cc index d3f73aa..935453e 100644 --- a/net/http/http_network_session.cc +++ b/net/http/http_network_session.cc @@ -114,7 +114,7 @@ HttpNetworkSession::Params::Params() quic_packet_loss_threshold(1.0f), quic_socket_receive_buffer_size(kQuicSocketReceiveBufferSize), quic_delay_tcp_race(false), - quic_store_server_configs_in_properties(false), + quic_max_server_configs_stored_in_properties(0u), quic_clock(NULL), quic_random(NULL), quic_max_packet_length(kDefaultMaxPacketSize), @@ -176,7 +176,7 @@ HttpNetworkSession::HttpNetworkSession(const Params& params) params.quic_threshold_timeouts_streams_open, params.quic_socket_receive_buffer_size, params.quic_delay_tcp_race, - params.quic_store_server_configs_in_properties, + params.quic_max_server_configs_stored_in_properties, params.quic_close_sessions_on_ip_change, params.quic_idle_connection_timeout_seconds, params.quic_migrate_sessions_on_network_change, @@ -239,6 +239,8 @@ HttpNetworkSession::HttpNetworkSession(const Params& params) http_server_properties_->SetAlternativeServiceProbabilityThreshold( params.alternative_service_probability_threshold); + http_server_properties_->SetMaxServerConfigsStoredInProperties( + params.quic_max_server_configs_stored_in_properties); } HttpNetworkSession::~HttpNetworkSession() { @@ -324,8 +326,8 @@ scoped_ptr<base::Value> HttpNetworkSession::QuicInfoToValue() const { params_.quic_max_number_of_lossy_connections); dict->SetDouble("packet_loss_threshold", params_.quic_packet_loss_threshold); dict->SetBoolean("delay_tcp_race", params_.quic_delay_tcp_race); - dict->SetBoolean("store_server_configs_in_properties", - params_.quic_store_server_configs_in_properties); + dict->SetInteger("max_server_configs_stored_in_properties", + params_.quic_max_server_configs_stored_in_properties); dict->SetInteger("idle_connection_timeout_seconds", params_.quic_idle_connection_timeout_seconds); dict->SetBoolean("disable_preconnect_if_0rtt", diff --git a/net/http/http_network_session.h b/net/http/http_network_session.h index 09b4d7e..9f98489 100644 --- a/net/http/http_network_session.h +++ b/net/http/http_network_session.h @@ -154,8 +154,9 @@ class NET_EXPORT HttpNetworkSession // Delay starting a TCP connection when QUIC believes it can speak // 0-RTT to a server. bool quic_delay_tcp_race; - // Store server configs in HttpServerProperties, instead of the disk cache. - bool quic_store_server_configs_in_properties; + // Maximum number of server configs that are to be stored in + // HttpServerProperties, instead of the disk cache. + size_t quic_max_server_configs_stored_in_properties; // If not empty, QUIC will be used for all connections to this origin. HostPortPair origin_to_force_quic_on; // Source of time for QUIC connections. Will be owned by QuicStreamFactory. diff --git a/net/http/http_server_properties.h b/net/http/http_server_properties.h index ec3433e..b8ea59b 100644 --- a/net/http/http_server_properties.h +++ b/net/http/http_server_properties.h @@ -379,6 +379,13 @@ class NET_EXPORT HttpServerProperties { // Returns all persistent QuicServerInfo objects. virtual const QuicServerInfoMap& quic_server_info_map() const = 0; + // Returns the number of server configs (QuicServerInfo objects) persisted. + virtual size_t max_server_configs_stored_in_properties() const = 0; + + // Sets the number of server configs (QuicServerInfo objects) to be persisted. + virtual void SetMaxServerConfigsStoredInProperties( + size_t max_server_configs_stored_in_properties) = 0; + private: DISALLOW_COPY_AND_ASSIGN(HttpServerProperties); }; diff --git a/net/http/http_server_properties_impl.cc b/net/http/http_server_properties_impl.cc index 89754d2..662aab6 100644 --- a/net/http/http_server_properties_impl.cc +++ b/net/http/http_server_properties_impl.cc @@ -33,7 +33,8 @@ HttpServerPropertiesImpl::HttpServerPropertiesImpl() spdy_settings_map_(SpdySettingsMap::NO_AUTO_EVICT), server_network_stats_map_(ServerNetworkStatsMap::NO_AUTO_EVICT), alternative_service_probability_threshold_(1.0), - quic_server_info_map_(kMaxQuicServersToPersist), + quic_server_info_map_(QuicServerInfoMap::NO_AUTO_EVICT), + max_server_configs_stored_in_properties_(kMaxQuicServersToPersist), weak_ptr_factory_(this) { canonical_suffixes_.push_back(".c.youtube.com"); canonical_suffixes_.push_back(".googlevideo.com"); @@ -184,7 +185,7 @@ void HttpServerPropertiesImpl::InitializeServerNetworkStats( void HttpServerPropertiesImpl::InitializeQuicServerInfoMap( QuicServerInfoMap* quic_server_info_map) { // Add the entries from persisted data. - QuicServerInfoMap temp_map(kMaxQuicServersToPersist); + QuicServerInfoMap temp_map(QuicServerInfoMap::NO_AUTO_EVICT); for (QuicServerInfoMap::reverse_iterator it = quic_server_info_map->rbegin(); it != quic_server_info_map->rend(); ++it) { temp_map.Put(it->first, it->second); @@ -676,6 +677,28 @@ const QuicServerInfoMap& HttpServerPropertiesImpl::quic_server_info_map() return quic_server_info_map_; } +size_t HttpServerPropertiesImpl::max_server_configs_stored_in_properties() + const { + return max_server_configs_stored_in_properties_; +} + +void HttpServerPropertiesImpl::SetMaxServerConfigsStoredInProperties( + size_t max_server_configs_stored_in_properties) { + max_server_configs_stored_in_properties_ = + max_server_configs_stored_in_properties; + + // MRUCache doesn't allow the size of the cache to be changed. Thus create a + // new map with the new size and add current elements and swap the new map. + quic_server_info_map_.ShrinkToSize(max_server_configs_stored_in_properties_); + QuicServerInfoMap temp_map(max_server_configs_stored_in_properties_); + for (QuicServerInfoMap::reverse_iterator it = quic_server_info_map_.rbegin(); + it != quic_server_info_map_.rend(); ++it) { + temp_map.Put(it->first, it->second); + } + + quic_server_info_map_.Swap(temp_map); +} + void HttpServerPropertiesImpl::SetAlternativeServiceProbabilityThreshold( double threshold) { alternative_service_probability_threshold_ = threshold; diff --git a/net/http/http_server_properties_impl.h b/net/http/http_server_properties_impl.h index a169362..b8678be 100644 --- a/net/http/http_server_properties_impl.h +++ b/net/http/http_server_properties_impl.h @@ -134,6 +134,9 @@ class NET_EXPORT HttpServerPropertiesImpl const std::string& server_info) override; const std::string* GetQuicServerInfo(const QuicServerId& server_id) override; const QuicServerInfoMap& quic_server_info_map() const override; + size_t max_server_configs_stored_in_properties() const override; + void SetMaxServerConfigsStoredInProperties( + size_t max_server_configs_stored_in_properties) override; private: friend class HttpServerPropertiesImplPeer; @@ -187,6 +190,7 @@ class NET_EXPORT HttpServerPropertiesImpl double alternative_service_probability_threshold_; QuicServerInfoMap quic_server_info_map_; + size_t max_server_configs_stored_in_properties_; base::WeakPtrFactory<HttpServerPropertiesImpl> weak_ptr_factory_; diff --git a/net/http/http_server_properties_impl_unittest.cc b/net/http/http_server_properties_impl_unittest.cc index cf24fc7..a4e8131 100644 --- a/net/http/http_server_properties_impl_unittest.cc +++ b/net/http/http_server_properties_impl_unittest.cc @@ -1389,6 +1389,11 @@ TEST_F(QuicServerInfoServerPropertiesTest, Initialize) { HostPortPair google_server("www.google.com", 443); QuicServerId google_quic_server_id(google_server, PRIVACY_MODE_ENABLED); + EXPECT_EQ(QuicServerInfoMap::NO_AUTO_EVICT, + impl_.quic_server_info_map().max_size()); + impl_.SetMaxServerConfigsStoredInProperties(10); + EXPECT_EQ(10u, impl_.quic_server_info_map().max_size()); + // Check empty map. QuicServerInfoMap init_quic_server_info_map(QuicServerInfoMap::NO_AUTO_EVICT); impl_.InitializeQuicServerInfoMap(&init_quic_server_info_map); @@ -1449,6 +1454,22 @@ TEST_F(QuicServerInfoServerPropertiesTest, Initialize) { ++memory_map_it; EXPECT_EQ(memory_map_it->first, mail_quic_server_id); EXPECT_EQ(mail_server_info, memory_map_it->second); + + // Shrink the size of |quic_server_info_map| and verify the MRU order is + // maintained. + impl_.SetMaxServerConfigsStoredInProperties(2); + EXPECT_EQ(2u, impl_.quic_server_info_map().max_size()); + + const QuicServerInfoMap& memory_map1 = impl_.quic_server_info_map(); + ASSERT_EQ(2u, memory_map1.size()); + QuicServerInfoMap::const_iterator memory_map1_it = memory_map1.begin(); + EXPECT_EQ(memory_map1_it->first, docs_quic_server_id); + EXPECT_EQ(new_docs_server_info, memory_map1_it->second); + ++memory_map1_it; + EXPECT_EQ(memory_map1_it->first, google_quic_server_id); + EXPECT_EQ(google_server_info, memory_map1_it->second); + // |QuicServerInfo| for |mail_quic_server_id| shouldn't be there. + EXPECT_EQ(nullptr, impl_.GetQuicServerInfo(mail_quic_server_id)); } TEST_F(QuicServerInfoServerPropertiesTest, SetQuicServerInfo) { diff --git a/net/http/http_server_properties_manager.cc b/net/http/http_server_properties_manager.cc index 70dc3e8..f7493ff 100644 --- a/net/http/http_server_properties_manager.cc +++ b/net/http/http_server_properties_manager.cc @@ -406,6 +406,20 @@ const QuicServerInfoMap& HttpServerPropertiesManager::quic_server_info_map() return http_server_properties_impl_->quic_server_info_map(); } +size_t HttpServerPropertiesManager::max_server_configs_stored_in_properties() + const { + DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); + return http_server_properties_impl_ + ->max_server_configs_stored_in_properties(); +} + +void HttpServerPropertiesManager::SetMaxServerConfigsStoredInProperties( + size_t max_server_configs_stored_in_properties) { + DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); + return http_server_properties_impl_->SetMaxServerConfigsStoredInProperties( + max_server_configs_stored_in_properties); +} + // // Update the HttpServerPropertiesImpl's cache with data from preferences. // @@ -497,7 +511,7 @@ void HttpServerPropertiesManager::UpdateCacheFromPrefsOnPrefThread() { scoped_ptr<ServerNetworkStatsMap> server_network_stats_map( new ServerNetworkStatsMap(kMaxServerNetworkStatsHostsToPersist)); scoped_ptr<QuicServerInfoMap> quic_server_info_map( - new QuicServerInfoMap(kMaxQuicServersToPersist)); + new QuicServerInfoMap(QuicServerInfoMap::NO_AUTO_EVICT)); if (version < 4) { if (!AddServersData(*servers_dict, spdy_servers.get(), @@ -980,7 +994,8 @@ void HttpServerPropertiesManager::UpdatePrefsFromCacheOnNetworkThread( const QuicServerInfoMap& main_quic_server_info_map = http_server_properties_impl_->quic_server_info_map(); if (main_quic_server_info_map.size() > 0) { - quic_server_info_map = new QuicServerInfoMap(kMaxQuicServersToPersist); + quic_server_info_map = + new QuicServerInfoMap(max_server_configs_stored_in_properties()); for (const std::pair<const QuicServerId, std::string>& entry : main_quic_server_info_map) { quic_server_info_map->Put(entry.first, entry.second); diff --git a/net/http/http_server_properties_manager.h b/net/http/http_server_properties_manager.h index 6779a21..b08ae16 100644 --- a/net/http/http_server_properties_manager.h +++ b/net/http/http_server_properties_manager.h @@ -134,6 +134,9 @@ class NET_EXPORT HttpServerPropertiesManager : public HttpServerProperties { const std::string& server_info) override; const std::string* GetQuicServerInfo(const QuicServerId& server_id) override; const QuicServerInfoMap& quic_server_info_map() const override; + size_t max_server_configs_stored_in_properties() const override; + void SetMaxServerConfigsStoredInProperties( + size_t max_server_configs_stored_in_properties) override; protected: // The location where ScheduleUpdatePrefsOnNetworkThread was called. diff --git a/net/http/http_server_properties_manager_unittest.cc b/net/http/http_server_properties_manager_unittest.cc index 4256ae4..49d19db 100644 --- a/net/http/http_server_properties_manager_unittest.cc +++ b/net/http/http_server_properties_manager_unittest.cc @@ -276,7 +276,9 @@ TEST_P(HttpServerPropertiesManagerTest, http_server_properties_dict->SetWithoutPathExpansion("supports_quic", supports_quic); - // Set quic_server_info for www.google.com:80 and mail.google.com:80. + // Set quic_server_info for www.google.com:80, mail.google.com:80 and + // play.google.com:80 and verify the MRU. + http_server_props_manager_->SetMaxServerConfigsStoredInProperties(3); base::DictionaryValue* quic_servers_dict = new base::DictionaryValue; base::DictionaryValue* quic_server_pref_dict1 = new base::DictionaryValue; std::string quic_server_info1("quic_server_info1"); @@ -286,6 +288,10 @@ TEST_P(HttpServerPropertiesManagerTest, std::string quic_server_info2("quic_server_info2"); quic_server_pref_dict2->SetStringWithoutPathExpansion("server_info", quic_server_info2); + base::DictionaryValue* quic_server_pref_dict3 = new base::DictionaryValue; + std::string quic_server_info3("quic_server_info3"); + quic_server_pref_dict3->SetStringWithoutPathExpansion("server_info", + quic_server_info3); // Set the quic_server_info1 for www.google.com server. QuicServerId google_quic_server_id("www.google.com", 80); quic_servers_dict->SetWithoutPathExpansion(google_quic_server_id.ToString(), @@ -294,6 +300,10 @@ TEST_P(HttpServerPropertiesManagerTest, QuicServerId mail_quic_server_id("mail.google.com", 80); quic_servers_dict->SetWithoutPathExpansion(mail_quic_server_id.ToString(), quic_server_pref_dict2); + // Set the quic_server_info3 for play.google.com server. + QuicServerId play_quic_server_id("play.google.com", 80); + quic_servers_dict->SetWithoutPathExpansion(play_quic_server_id.ToString(), + quic_server_pref_dict3); http_server_properties_dict->SetWithoutPathExpansion("quic_servers", quic_servers_dict); @@ -375,6 +385,17 @@ TEST_P(HttpServerPropertiesManagerTest, google_quic_server_id)); EXPECT_EQ(quic_server_info2, *http_server_props_manager_->GetQuicServerInfo( mail_quic_server_id)); + EXPECT_EQ(quic_server_info3, *http_server_props_manager_->GetQuicServerInfo( + play_quic_server_id)); + + // Verify the MRU order. + http_server_props_manager_->SetMaxServerConfigsStoredInProperties(2); + EXPECT_EQ(nullptr, http_server_props_manager_->GetQuicServerInfo( + google_quic_server_id)); + EXPECT_EQ(quic_server_info2, *http_server_props_manager_->GetQuicServerInfo( + mail_quic_server_id)); + EXPECT_EQ(quic_server_info3, *http_server_props_manager_->GetQuicServerInfo( + play_quic_server_id)); } TEST_P(HttpServerPropertiesManagerTest, BadCachedHostPortPair) { diff --git a/net/quic/quic_stream_factory.cc b/net/quic/quic_stream_factory.cc index f05c1176..858f1cb 100644 --- a/net/quic/quic_stream_factory.cc +++ b/net/quic/quic_stream_factory.cc @@ -566,7 +566,7 @@ QuicStreamFactory::QuicStreamFactory( int threshold_timeouts_with_open_streams, int socket_receive_buffer_size, bool delay_tcp_race, - bool store_server_configs_in_properties, + int max_server_configs_stored_in_properties, bool close_sessions_on_ip_change, int idle_connection_timeout_seconds, bool migrate_sessions_on_network_change, @@ -615,7 +615,6 @@ QuicStreamFactory::QuicStreamFactory( yield_after_packets_(kQuicYieldAfterPacketsRead), yield_after_duration_(QuicTime::Delta::FromMilliseconds( kQuicYieldAfterDurationMilliseconds)), - store_server_configs_in_properties_(store_server_configs_in_properties), close_sessions_on_ip_change_(close_sessions_on_ip_change), migrate_sessions_on_network_change_( migrate_sessions_on_network_change && @@ -653,7 +652,7 @@ QuicStreamFactory::QuicStreamFactory( // When disk cache is used to store the server configs, HttpCache code calls // |set_quic_server_info_factory| if |quic_server_info_factory_| wasn't // created. - if (store_server_configs_in_properties_) { + if (max_server_configs_stored_in_properties > 0) { quic_server_info_factory_.reset( new PropertiesBasedQuicServerInfoFactory(http_server_properties_)); } @@ -1546,7 +1545,7 @@ void QuicStreamFactory::MaybeInitialize() { } } - if (!store_server_configs_in_properties_) + if (http_server_properties_->max_server_configs_stored_in_properties() == 0) return; // Create a temporary QuicServerInfo object to deserialize and to populate the // in-memory crypto server config cache. diff --git a/net/quic/quic_stream_factory.h b/net/quic/quic_stream_factory.h index b0a8999..9a7cfe5 100644 --- a/net/quic/quic_stream_factory.h +++ b/net/quic/quic_stream_factory.h @@ -147,7 +147,7 @@ class NET_EXPORT_PRIVATE QuicStreamFactory int threshold_public_resets_post_handshake, int socket_receive_buffer_size, bool delay_tcp_race, - bool store_server_configs_in_properties, + int max_server_configs_stored_in_properties, bool close_sessions_on_ip_change, int idle_connection_timeout_seconds, bool migrate_sessions_on_network_change, @@ -276,7 +276,7 @@ class NET_EXPORT_PRIVATE QuicStreamFactory bool enable_port_selection() const { return enable_port_selection_; } bool has_quic_server_info_factory() { - return !quic_server_info_factory_.get(); + return quic_server_info_factory_.get() != nullptr; } void set_quic_server_info_factory( @@ -291,10 +291,6 @@ class NET_EXPORT_PRIVATE QuicStreamFactory bool delay_tcp_race() const { return delay_tcp_race_; } - bool store_server_configs_in_properties() const { - return store_server_configs_in_properties_; - } - private: class Job; friend class test::QuicStreamFactoryPeer; @@ -482,9 +478,6 @@ class NET_EXPORT_PRIVATE QuicStreamFactory int yield_after_packets_; QuicTime::Delta yield_after_duration_; - // Set if server configs are to be stored in HttpServerProperties. - bool store_server_configs_in_properties_; - // Set if all sessions should be closed when any local IP address changes. const bool close_sessions_on_ip_change_; diff --git a/net/quic/quic_stream_factory_test.cc b/net/quic/quic_stream_factory_test.cc index 1e1e1d6..8754453 100644 --- a/net/quic/quic_stream_factory_test.cc +++ b/net/quic/quic_stream_factory_test.cc @@ -217,7 +217,6 @@ class QuicStreamFactoryTest : public ::testing::TestWithParam<TestParams> { threshold_public_resets_post_handshake_(2), receive_buffer_size_(0), delay_tcp_race_(false), - store_server_configs_in_properties_(false), close_sessions_on_ip_change_(false), idle_connection_timeout_seconds_(kIdleConnectionTimeoutSeconds), migrate_sessions_on_network_change_(false) { @@ -239,11 +238,13 @@ class QuicStreamFactoryTest : public ::testing::TestWithParam<TestParams> { max_number_of_lossy_connections_, packet_loss_threshold_, max_disabled_reasons_, threshold_timeouts_with_open_streams_, threshold_public_resets_post_handshake_, receive_buffer_size_, - delay_tcp_race_, store_server_configs_in_properties_, + delay_tcp_race_, /*max_server_configs_stored_in_properties*/ 0, close_sessions_on_ip_change_, idle_connection_timeout_seconds_, migrate_sessions_on_network_change_, QuicTagVector())); factory_->set_require_confirmation(false); + EXPECT_FALSE(factory_->has_quic_server_info_factory()); factory_->set_quic_server_info_factory(new MockQuicServerInfoFactory()); + EXPECT_TRUE(factory_->has_quic_server_info_factory()); } void InitializeConnectionMigrationTest( @@ -411,7 +412,6 @@ class QuicStreamFactoryTest : public ::testing::TestWithParam<TestParams> { int threshold_public_resets_post_handshake_; int receive_buffer_size_; bool delay_tcp_race_; - bool store_server_configs_in_properties_; bool close_sessions_on_ip_change_; int idle_connection_timeout_seconds_; bool migrate_sessions_on_network_change_; @@ -3099,7 +3099,6 @@ TEST_P(QuicStreamFactoryTest, EnableDelayTcpRace) { } TEST_P(QuicStreamFactoryTest, MaybeInitialize) { - store_server_configs_in_properties_ = true; idle_connection_timeout_seconds_ = 500; Initialize(); ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); @@ -3118,6 +3117,8 @@ TEST_P(QuicStreamFactoryTest, MaybeInitialize) { http_server_properties_.SetAlternativeServices( host_port_pair_, alternative_service_info_vector); + http_server_properties_.SetMaxServerConfigsStoredInProperties( + kMaxQuicServersToPersist); QuicServerId quic_server_id(kDefaultServerHostName, 80, PRIVACY_MODE_DISABLED); diff --git a/net/url_request/url_request_context_builder.cc b/net/url_request/url_request_context_builder.cc index f00cad5..3112f1f 100644 --- a/net/url_request/url_request_context_builder.cc +++ b/net/url_request/url_request_context_builder.cc @@ -182,7 +182,7 @@ URLRequestContextBuilder::HttpNetworkSessionParams::HttpNetworkSessionParams() next_protos(NextProtosDefaults()), use_alternative_services(true), enable_quic(false), - quic_store_server_configs_in_properties(false), + quic_max_server_configs_stored_in_properties(0), quic_delay_tcp_race(false), quic_max_number_of_lossy_connections(0), quic_packet_loss_threshold(1.0f), @@ -391,8 +391,8 @@ scoped_ptr<URLRequestContext> URLRequestContextBuilder::Build() { http_network_session_params_.trusted_spdy_proxy; network_session_params.next_protos = http_network_session_params_.next_protos; network_session_params.enable_quic = http_network_session_params_.enable_quic; - network_session_params.quic_store_server_configs_in_properties = - http_network_session_params_.quic_store_server_configs_in_properties; + network_session_params.quic_max_server_configs_stored_in_properties = + http_network_session_params_.quic_max_server_configs_stored_in_properties; network_session_params.quic_delay_tcp_race = http_network_session_params_.quic_delay_tcp_race; network_session_params.quic_max_number_of_lossy_connections = diff --git a/net/url_request/url_request_context_builder.h b/net/url_request/url_request_context_builder.h index 0a58c81..b955c96 100644 --- a/net/url_request/url_request_context_builder.h +++ b/net/url_request/url_request_context_builder.h @@ -88,7 +88,7 @@ class NET_EXPORT URLRequestContextBuilder { std::string trusted_spdy_proxy; bool use_alternative_services; bool enable_quic; - bool quic_store_server_configs_in_properties; + int quic_max_server_configs_stored_in_properties; bool quic_delay_tcp_race; int quic_max_number_of_lossy_connections; std::unordered_set<std::string> quic_host_whitelist; @@ -198,10 +198,10 @@ class NET_EXPORT URLRequestContextBuilder { quic_connection_options; } - void set_quic_store_server_configs_in_properties( - bool quic_store_server_configs_in_properties) { - http_network_session_params_.quic_store_server_configs_in_properties = - quic_store_server_configs_in_properties; + void set_quic_max_server_configs_stored_in_properties( + int quic_max_server_configs_stored_in_properties) { + http_network_session_params_.quic_max_server_configs_stored_in_properties = + quic_max_server_configs_stored_in_properties; } void set_quic_delay_tcp_race(bool quic_delay_tcp_race) { |