| 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 6d705f1eb6bb61a18492d7f9c8afea9e262011b7..de94dfed7e38e082f1a3fcc41e03c32e70ec3311 100644
|
| --- a/net/http/http_server_properties_impl.cc
|
| +++ b/net/http/http_server_properties_impl.cc
|
| @@ -19,8 +19,7 @@
|
| static const int kDefaultNumHostsToRemember = 200;
|
|
|
| HttpServerPropertiesImpl::HttpServerPropertiesImpl()
|
| - : alternate_protocol_map_(AlternateProtocolMap::NO_AUTO_EVICT),
|
| - pipeline_capability_map_(
|
| + : pipeline_capability_map_(
|
| new CachedPipelineCapabilityMap(kDefaultNumHostsToRemember)),
|
| weak_ptr_factory_(this) {
|
| canoncial_suffixes_.push_back(".c.youtube.com");
|
| @@ -45,24 +44,15 @@
|
|
|
| void HttpServerPropertiesImpl::InitializeAlternateProtocolServers(
|
| AlternateProtocolMap* alternate_protocol_map) {
|
| - // Keep all the ALTERNATE_PROTOCOL_BROKEN ones since those don't
|
| - // get persisted.
|
| - for (AlternateProtocolMap::iterator it = alternate_protocol_map_.begin();
|
| - it != alternate_protocol_map_.end();) {
|
| - AlternateProtocolMap::iterator old_it = it;
|
| - ++it;
|
| - if (old_it->second.protocol != ALTERNATE_PROTOCOL_BROKEN) {
|
| - alternate_protocol_map_.Erase(old_it);
|
| - }
|
| - }
|
| -
|
| - // Add the entries from persisted data.
|
| - for (AlternateProtocolMap::reverse_iterator it =
|
| - alternate_protocol_map->rbegin();
|
| - it != alternate_protocol_map->rend(); ++it) {
|
| - alternate_protocol_map_.Put(it->first, it->second);
|
| - }
|
| -
|
| + // First swap, and then add back all the ALTERNATE_PROTOCOL_BROKEN ones since
|
| + // those don't get persisted.
|
| + alternate_protocol_map_.swap(*alternate_protocol_map);
|
| + for (AlternateProtocolMap::const_iterator it =
|
| + alternate_protocol_map->begin();
|
| + it != alternate_protocol_map->end(); ++it) {
|
| + if (it->second.protocol == ALTERNATE_PROTOCOL_BROKEN)
|
| + alternate_protocol_map_[it->first] = it->second;
|
| + }
|
| // Attempt to find canonical servers.
|
| int canonical_ports[] = { 80, 443 };
|
| for (size_t i = 0; i < canoncial_suffixes_.size(); ++i) {
|
| @@ -71,8 +61,8 @@
|
| HostPortPair canonical_host(canonical_suffix, canonical_ports[j]);
|
| // If we already have a valid canonical server, we're done.
|
| if (ContainsKey(canonical_host_to_origin_map_, canonical_host) &&
|
| - (alternate_protocol_map_.Peek(canonical_host_to_origin_map_[
|
| - canonical_host]) != alternate_protocol_map_.end())) {
|
| + ContainsKey(alternate_protocol_map_,
|
| + canonical_host_to_origin_map_[canonical_host])) {
|
| continue;
|
| }
|
| // Now attempt to find a server which matches this origin and set it as
|
| @@ -157,7 +147,7 @@
|
| void HttpServerPropertiesImpl::Clear() {
|
| DCHECK(CalledOnValidThread());
|
| spdy_servers_table_.clear();
|
| - alternate_protocol_map_.Clear();
|
| + alternate_protocol_map_.clear();
|
| spdy_settings_map_.clear();
|
| pipeline_capability_map_->Clear();
|
| }
|
| @@ -195,8 +185,8 @@
|
| }
|
|
|
| bool HttpServerPropertiesImpl::HasAlternateProtocol(
|
| - const HostPortPair& server) {
|
| - if (alternate_protocol_map_.Get(server) != alternate_protocol_map_.end() ||
|
| + const HostPortPair& server) const {
|
| + if (ContainsKey(alternate_protocol_map_, server) ||
|
| g_forced_alternate_protocol)
|
| return true;
|
|
|
| @@ -205,18 +195,19 @@
|
|
|
| PortAlternateProtocolPair
|
| HttpServerPropertiesImpl::GetAlternateProtocol(
|
| - const HostPortPair& server) {
|
| + const HostPortPair& server) const {
|
| DCHECK(HasAlternateProtocol(server));
|
|
|
| // First check the map.
|
| - AlternateProtocolMap::iterator it = alternate_protocol_map_.Get(server);
|
| + AlternateProtocolMap::const_iterator it =
|
| + alternate_protocol_map_.find(server);
|
| if (it != alternate_protocol_map_.end())
|
| return it->second;
|
|
|
| // Next check the canonical host.
|
| CanonicalHostMap::const_iterator canonical_host = GetCanonicalHost(server);
|
| if (canonical_host != canonical_host_to_origin_map_.end())
|
| - return alternate_protocol_map_.Get(canonical_host->second)->second;
|
| + return alternate_protocol_map_.find(canonical_host->second)->second;
|
|
|
| // We must be forcing an alternate.
|
| DCHECK(g_forced_alternate_protocol);
|
| @@ -256,7 +247,7 @@
|
| }
|
| }
|
|
|
| - alternate_protocol_map_.Put(server, alternate);
|
| + alternate_protocol_map_[server] = alternate;
|
|
|
| // If this host ends with a canonical suffix, then set it as the
|
| // canonical host.
|
| @@ -272,14 +263,7 @@
|
|
|
| void HttpServerPropertiesImpl::SetBrokenAlternateProtocol(
|
| const HostPortPair& server) {
|
| - AlternateProtocolMap::iterator it = alternate_protocol_map_.Get(server);
|
| - if (it != alternate_protocol_map_.end()) {
|
| - it->second.protocol = ALTERNATE_PROTOCOL_BROKEN;
|
| - return;
|
| - }
|
| - PortAlternateProtocolPair alternate;
|
| - alternate.protocol = ALTERNATE_PROTOCOL_BROKEN;
|
| - alternate_protocol_map_.Put(server, alternate);
|
| + alternate_protocol_map_[server].protocol = ALTERNATE_PROTOCOL_BROKEN;
|
| }
|
|
|
| const AlternateProtocolMap&
|
|
|