Index: chrome/browser/net/http_server_properties_manager.cc |
diff --git a/chrome/browser/net/http_server_properties_manager.cc b/chrome/browser/net/http_server_properties_manager.cc |
index 1bde25e4109bab522b0f74f053d5bda727562a0b..3b1c2e8e3ad556230df9ea5b6b4ced4c25f57274 100644 |
--- a/chrome/browser/net/http_server_properties_manager.cc |
+++ b/chrome/browser/net/http_server_properties_manager.cc |
@@ -43,6 +43,9 @@ const int kVersionNumber = 2; |
typedef std::vector<std::string> StringVector; |
+// Persist 200 MRU AlternateProtocolHostPortPairs. |
+const int kMaxAlternateProtocolHostsToPersist = 200; |
+ |
} // namespace |
//////////////////////////////////////////////////////////////////////////////// |
@@ -148,14 +151,14 @@ void HttpServerPropertiesManager::SetSupportsSpdy( |
} |
bool HttpServerPropertiesManager::HasAlternateProtocol( |
- const net::HostPortPair& server) const { |
+ const net::HostPortPair& server) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
return http_server_properties_impl_->HasAlternateProtocol(server); |
} |
net::PortAlternateProtocolPair |
HttpServerPropertiesManager::GetAlternateProtocol( |
- const net::HostPortPair& server) const { |
+ const net::HostPortPair& server) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
return http_server_properties_impl_->GetAlternateProtocol(server); |
} |
@@ -320,7 +323,7 @@ void HttpServerPropertiesManager::UpdateCacheFromPrefsOnUI() { |
scoped_ptr<net::PipelineCapabilityMap> pipeline_capability_map( |
new net::PipelineCapabilityMap); |
scoped_ptr<net::AlternateProtocolMap> alternate_protocol_map( |
- new net::AlternateProtocolMap); |
+ new net::AlternateProtocolMap(kMaxAlternateProtocolHostsToPersist)); |
for (base::DictionaryValue::Iterator it(*servers_dict); !it.IsAtEnd(); |
it.Advance()) { |
@@ -386,7 +389,8 @@ void HttpServerPropertiesManager::UpdateCacheFromPrefsOnUI() { |
} |
// Get alternate_protocol server. |
- DCHECK(!ContainsKey(*alternate_protocol_map, server)); |
+ DCHECK(alternate_protocol_map->Peek(server) == |
+ alternate_protocol_map->end()); |
const base::DictionaryValue* port_alternate_protocol_dict = NULL; |
if (!server_pref_dict->GetDictionaryWithoutPathExpansion( |
"alternate_protocol", &port_alternate_protocol_dict)) { |
@@ -420,7 +424,7 @@ void HttpServerPropertiesManager::UpdateCacheFromPrefsOnUI() { |
port_alternate_protocol.port = port; |
port_alternate_protocol.protocol = protocol; |
- (*alternate_protocol_map)[server] = port_alternate_protocol; |
+ alternate_protocol_map->Put(server, port_alternate_protocol); |
} while (false); |
} |
@@ -509,9 +513,15 @@ void HttpServerPropertiesManager::UpdatePrefsFromCacheOnIO( |
*spdy_settings_map = http_server_properties_impl_->spdy_settings_map(); |
net::AlternateProtocolMap* alternate_protocol_map = |
- new net::AlternateProtocolMap; |
- *alternate_protocol_map = |
+ new net::AlternateProtocolMap(kMaxAlternateProtocolHostsToPersist); |
+ const net::AlternateProtocolMap& map = |
http_server_properties_impl_->alternate_protocol_map(); |
+ int count = 0; |
+ for (net::AlternateProtocolMap::const_iterator it = map.begin(); |
+ it != map.end() && count < kMaxAlternateProtocolHostsToPersist; |
+ ++it, ++count) { |
+ alternate_protocol_map->Put(it->first, it->second); |
+ } |
net::PipelineCapabilityMap* pipeline_capability_map = |
new net::PipelineCapabilityMap; |
@@ -585,8 +595,7 @@ void HttpServerPropertiesManager::UpdatePrefsOnUI( |
} |
// Add servers that have SpdySettings to server_pref_map. |
- for (net::SpdySettingsMap::iterator map_it = |
- spdy_settings_map->begin(); |
+ for (net::SpdySettingsMap::iterator map_it = spdy_settings_map->begin(); |
map_it != spdy_settings_map->end(); ++map_it) { |
const net::HostPortPair& server = map_it->first; |
@@ -601,7 +610,7 @@ void HttpServerPropertiesManager::UpdatePrefsOnUI( |
// Add AlternateProtocol servers to server_pref_map. |
for (net::AlternateProtocolMap::const_iterator map_it = |
- alternate_protocol_map->begin(); |
+ alternate_protocol_map->begin(); |
map_it != alternate_protocol_map->end(); ++map_it) { |
const net::HostPortPair& server = map_it->first; |
const net::PortAlternateProtocolPair& port_alternate_protocol = |