Index: net/http/http_server_properties_impl.cc |
diff --git a/net/http/http_server_properties_impl.cc b/net/http/http_server_properties_impl.cc |
index 3968b1a3eb82e100de4a68908052964feff6ed6e..51771886034c82656d264b705057ba30ed0a99a3 100644 |
--- a/net/http/http_server_properties_impl.cc |
+++ b/net/http/http_server_properties_impl.cc |
@@ -27,10 +27,11 @@ const uint64 kBrokenAlternateProtocolDelaySecs = 300; |
} // namespace |
HttpServerPropertiesImpl::HttpServerPropertiesImpl() |
- : alternate_protocol_map_(AlternateProtocolMap::NO_AUTO_EVICT), |
+ : spdy_servers_map_(SpdyServerHostPortMap::NO_AUTO_EVICT), |
+ alternate_protocol_map_(AlternateProtocolMap::NO_AUTO_EVICT), |
spdy_settings_map_(SpdySettingsMap::NO_AUTO_EVICT), |
pipeline_capability_map_( |
- new CachedPipelineCapabilityMap(kDefaultNumHostsToRemember)), |
+ new CachedPipelineCapabilityMap(kDefaultNumHostsToRemember)), |
weak_ptr_factory_(this) { |
canoncial_suffixes_.push_back(".c.youtube.com"); |
canoncial_suffixes_.push_back(".googlevideo.com"); |
@@ -43,12 +44,12 @@ void HttpServerPropertiesImpl::InitializeSpdyServers( |
std::vector<std::string>* spdy_servers, |
bool support_spdy) { |
DCHECK(CalledOnValidThread()); |
- spdy_servers_table_.clear(); |
if (!spdy_servers) |
return; |
- for (std::vector<std::string>::iterator it = spdy_servers->begin(); |
- it != spdy_servers->end(); ++it) { |
- spdy_servers_table_[*it] = support_spdy; |
+ // Add the entries from persisted data. |
+ for (std::vector<std::string>::reverse_iterator it = spdy_servers->rbegin(); |
+ it != spdy_servers->rend(); ++it) { |
+ spdy_servers_map_.Put(*it, support_spdy); |
} |
} |
@@ -122,16 +123,20 @@ void HttpServerPropertiesImpl::SetNumPipelinedHostsToRemember(int max_size) { |
} |
void HttpServerPropertiesImpl::GetSpdyServerList( |
- base::ListValue* spdy_server_list) const { |
+ base::ListValue* spdy_server_list, |
+ size_t max_size) const { |
DCHECK(CalledOnValidThread()); |
DCHECK(spdy_server_list); |
spdy_server_list->Clear(); |
+ size_t count = 0; |
// Get the list of servers (host/port) that support SPDY. |
- for (SpdyServerHostPortTable::const_iterator it = spdy_servers_table_.begin(); |
- it != spdy_servers_table_.end(); ++it) { |
+ for (SpdyServerHostPortMap::const_iterator it = spdy_servers_map_.begin(); |
+ it != spdy_servers_map_.end() && count < max_size; ++it) { |
const std::string spdy_server_host_port = it->first; |
- if (it->second) |
+ if (it->second) { |
spdy_server_list->Append(new base::StringValue(spdy_server_host_port)); |
+ ++count; |
+ } |
} |
} |
@@ -168,22 +173,22 @@ base::WeakPtr<HttpServerProperties> HttpServerPropertiesImpl::GetWeakPtr() { |
void HttpServerPropertiesImpl::Clear() { |
DCHECK(CalledOnValidThread()); |
- spdy_servers_table_.clear(); |
+ spdy_servers_map_.Clear(); |
alternate_protocol_map_.Clear(); |
spdy_settings_map_.Clear(); |
pipeline_capability_map_->Clear(); |
} |
bool HttpServerPropertiesImpl::SupportsSpdy( |
- const net::HostPortPair& host_port_pair) const { |
+ const net::HostPortPair& host_port_pair) { |
DCHECK(CalledOnValidThread()); |
if (host_port_pair.host().empty()) |
return false; |
std::string spdy_server = GetFlattenedSpdyServer(host_port_pair); |
- SpdyServerHostPortTable::const_iterator spdy_host_port = |
- spdy_servers_table_.find(spdy_server); |
- if (spdy_host_port != spdy_servers_table_.end()) |
+ SpdyServerHostPortMap::iterator spdy_host_port = |
+ spdy_servers_map_.Get(spdy_server); |
+ if (spdy_host_port != spdy_servers_map_.end()) |
return spdy_host_port->second; |
return false; |
} |
@@ -196,14 +201,14 @@ void HttpServerPropertiesImpl::SetSupportsSpdy( |
return; |
std::string spdy_server = GetFlattenedSpdyServer(host_port_pair); |
- SpdyServerHostPortTable::iterator spdy_host_port = |
- spdy_servers_table_.find(spdy_server); |
- if ((spdy_host_port != spdy_servers_table_.end()) && |
+ SpdyServerHostPortMap::iterator spdy_host_port = |
+ spdy_servers_map_.Get(spdy_server); |
+ if ((spdy_host_port != spdy_servers_map_.end()) && |
(spdy_host_port->second == support_spdy)) { |
return; |
} |
// Cache the data. |
- spdy_servers_table_[spdy_server] = support_spdy; |
+ spdy_servers_map_.Put(spdy_server, support_spdy); |
} |
bool HttpServerPropertiesImpl::HasAlternateProtocol( |