diff options
author | rtenneti <rtenneti@chromium.org> | 2015-06-05 14:55:23 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-05 21:55:57 +0000 |
commit | e267d6a5e8f7fd198c4ac5d11d7098a1d17228c5 (patch) | |
tree | 0e9beea0a44a30248289dfa63c81fb83b6d0ab68 /net | |
parent | d65e9c8f0dbf07d539f895c1f0155f4be9983963 (diff) | |
download | chromium_src-e267d6a5e8f7fd198c4ac5d11d7098a1d17228c5.zip chromium_src-e267d6a5e8f7fd198c4ac5d11d7098a1d17228c5.tar.gz chromium_src-e267d6a5e8f7fd198c4ac5d11d7098a1d17228c5.tar.bz2 |
HttpServerProperties - Don't persist if SetSupportsSpdy is called with
the same origin (HostPortPair) and value (supports_spdy).
This change reduces the number of times SetSupportsSpdy tries to persist
HttpServerProperties to disk (currently ~5% of persist calls are due to
SetSupportsSpdy).
BUG=451256
R=rch@chromium.org
Review URL: https://codereview.chromium.org/1159853005
Cr-Commit-Position: refs/heads/master@{#333146}
Diffstat (limited to 'net')
-rw-r--r-- | net/http/http_server_properties.h | 3 | ||||
-rw-r--r-- | net/http/http_server_properties_impl.cc | 15 | ||||
-rw-r--r-- | net/http/http_server_properties_impl.h | 1 | ||||
-rw-r--r-- | net/http/http_server_properties_manager.cc | 10 | ||||
-rw-r--r-- | net/http/http_server_properties_manager.h | 1 | ||||
-rw-r--r-- | net/http/http_server_properties_manager_unittest.cc | 2 |
6 files changed, 28 insertions, 4 deletions
diff --git a/net/http/http_server_properties.h b/net/http/http_server_properties.h index 78133dd..417a1d6 100644 --- a/net/http/http_server_properties.h +++ b/net/http/http_server_properties.h @@ -218,6 +218,9 @@ class NET_EXPORT HttpServerProperties { // request prioritization. virtual bool SupportsRequestPriority(const HostPortPair& server) = 0; + // Returns the value set by SetSupportsSpdy(). If not set, returns false. + virtual bool GetSupportsSpdy(const HostPortPair& server) = 0; + // Add |server| into the persistent store. Should only be called from IO // thread. virtual void SetSupportsSpdy(const HostPortPair& server, diff --git a/net/http/http_server_properties_impl.cc b/net/http/http_server_properties_impl.cc index 72b44ce..d72e488 100644 --- a/net/http/http_server_properties_impl.cc +++ b/net/http/http_server_properties_impl.cc @@ -157,9 +157,7 @@ bool HttpServerPropertiesImpl::SupportsRequestPriority( if (host_port_pair.host().empty()) return false; - SpdyServerHostPortMap::iterator spdy_host_port = - spdy_servers_map_.Get(host_port_pair.ToString()); - if (spdy_host_port != spdy_servers_map_.end() && spdy_host_port->second) + if (GetSupportsSpdy(host_port_pair)) return true; const AlternativeService alternative_service = @@ -167,6 +165,17 @@ bool HttpServerPropertiesImpl::SupportsRequestPriority( return alternative_service.protocol == QUIC; } +bool HttpServerPropertiesImpl::GetSupportsSpdy( + const HostPortPair& host_port_pair) { + DCHECK(CalledOnValidThread()); + if (host_port_pair.host().empty()) + return false; + + SpdyServerHostPortMap::iterator spdy_host_port = + spdy_servers_map_.Get(host_port_pair.ToString()); + return spdy_host_port != spdy_servers_map_.end() && spdy_host_port->second; +} + void HttpServerPropertiesImpl::SetSupportsSpdy( const HostPortPair& host_port_pair, bool support_spdy) { diff --git a/net/http/http_server_properties_impl.h b/net/http/http_server_properties_impl.h index 6096cf7..3ea0875 100644 --- a/net/http/http_server_properties_impl.h +++ b/net/http/http_server_properties_impl.h @@ -81,6 +81,7 @@ class NET_EXPORT HttpServerPropertiesImpl base::WeakPtr<HttpServerProperties> GetWeakPtr() override; void Clear() override; bool SupportsRequestPriority(const HostPortPair& server) override; + bool GetSupportsSpdy(const HostPortPair& server) override; void SetSupportsSpdy(const HostPortPair& server, bool support_spdy) override; bool RequiresHTTP11(const HostPortPair& server) override; void SetHTTP11Required(const HostPortPair& server) override; diff --git a/net/http/http_server_properties_manager.cc b/net/http/http_server_properties_manager.cc index 5836a83..25a68ce 100644 --- a/net/http/http_server_properties_manager.cc +++ b/net/http/http_server_properties_manager.cc @@ -155,12 +155,20 @@ bool HttpServerPropertiesManager::SupportsRequestPriority( return http_server_properties_impl_->SupportsRequestPriority(server); } +bool HttpServerPropertiesManager::GetSupportsSpdy(const HostPortPair& server) { + DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); + return http_server_properties_impl_->GetSupportsSpdy(server); +} + void HttpServerPropertiesManager::SetSupportsSpdy(const HostPortPair& server, bool support_spdy) { DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); + bool old_support_spdy = http_server_properties_impl_->GetSupportsSpdy(server); http_server_properties_impl_->SetSupportsSpdy(server, support_spdy); - ScheduleUpdatePrefsOnNetworkThread(SUPPORTS_SPDY); + bool new_support_spdy = http_server_properties_impl_->GetSupportsSpdy(server); + if (old_support_spdy != new_support_spdy) + ScheduleUpdatePrefsOnNetworkThread(SUPPORTS_SPDY); } bool HttpServerPropertiesManager::RequiresHTTP11(const HostPortPair& server) { diff --git a/net/http/http_server_properties_manager.h b/net/http/http_server_properties_manager.h index 3e4257a..a7f0d01 100644 --- a/net/http/http_server_properties_manager.h +++ b/net/http/http_server_properties_manager.h @@ -81,6 +81,7 @@ class NET_EXPORT HttpServerPropertiesManager : public HttpServerProperties { base::WeakPtr<HttpServerProperties> GetWeakPtr() override; void Clear() override; bool SupportsRequestPriority(const HostPortPair& server) override; + bool GetSupportsSpdy(const HostPortPair& server) override; void SetSupportsSpdy(const HostPortPair& server, bool support_spdy) override; bool RequiresHTTP11(const HostPortPair& server) override; void SetHTTP11Required(const HostPortPair& server) override; diff --git a/net/http/http_server_properties_manager_unittest.cc b/net/http/http_server_properties_manager_unittest.cc index be17d9a..79c1723 100644 --- a/net/http/http_server_properties_manager_unittest.cc +++ b/net/http/http_server_properties_manager_unittest.cc @@ -390,6 +390,8 @@ TEST_F(HttpServerPropertiesManagerTest, SupportsSpdy) { EXPECT_FALSE( http_server_props_manager_->SupportsRequestPriority(spdy_server_mail)); http_server_props_manager_->SetSupportsSpdy(spdy_server_mail, true); + // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once. + http_server_props_manager_->SetSupportsSpdy(spdy_server_mail, true); // Run the task. base::RunLoop().RunUntilIdle(); |