Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/http/http_server_properties_impl.h" | 5 #include "net/http/http_server_properties_impl.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| 11 | 11 |
| 12 namespace net { | 12 namespace net { |
| 13 | 13 |
| 14 HttpServerPropertiesImpl::HttpServerPropertiesImpl() { | 14 // TODO(simonjam): Run experiments with different values of this to see what |
| 15 // value is good at avoiding evictions without eating too much memory. Until | |
| 16 // then, this is just a bad guess. | |
|
willchan no longer on Chromium
2011/12/02 23:35:29
Good idea. But perhaps we should put this in the c
James Simonsen
2011/12/03 03:16:00
Hmm. I started in on this, but that constructor is
| |
| 17 static const int kNumHostsToRemember = 200; | |
| 18 | |
| 19 HttpServerPropertiesImpl::HttpServerPropertiesImpl() | |
| 20 : pipeline_capability_map_(kNumHostsToRemember) { | |
| 15 } | 21 } |
| 16 | 22 |
| 17 HttpServerPropertiesImpl::~HttpServerPropertiesImpl() { | 23 HttpServerPropertiesImpl::~HttpServerPropertiesImpl() { |
| 18 } | 24 } |
| 19 | 25 |
| 20 void HttpServerPropertiesImpl::InitializeSpdyServers( | 26 void HttpServerPropertiesImpl::InitializeSpdyServers( |
| 21 std::vector<std::string>* spdy_servers, | 27 std::vector<std::string>* spdy_servers, |
| 22 bool support_spdy) { | 28 bool support_spdy) { |
| 23 DCHECK(CalledOnValidThread()); | 29 DCHECK(CalledOnValidThread()); |
| 24 spdy_servers_table_.clear(); | 30 spdy_servers_table_.clear(); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 41 if (it->second.protocol == ALTERNATE_PROTOCOL_BROKEN) | 47 if (it->second.protocol == ALTERNATE_PROTOCOL_BROKEN) |
| 42 alternate_protocol_map_[it->first] = it->second; | 48 alternate_protocol_map_[it->first] = it->second; |
| 43 } | 49 } |
| 44 } | 50 } |
| 45 | 51 |
| 46 void HttpServerPropertiesImpl::InitializeSpdySettingsServers( | 52 void HttpServerPropertiesImpl::InitializeSpdySettingsServers( |
| 47 std::map<HostPortPair, spdy::SpdySettings>* spdy_settings_map) { | 53 std::map<HostPortPair, spdy::SpdySettings>* spdy_settings_map) { |
| 48 spdy_settings_map_.swap(*spdy_settings_map); | 54 spdy_settings_map_.swap(*spdy_settings_map); |
| 49 } | 55 } |
| 50 | 56 |
| 57 void HttpServerPropertiesImpl::InitializePipelineCapabilities( | |
| 58 PipelineCapabilityMap* pipeline_capability_map) { | |
| 59 PipelineCapabilityMap::const_iterator it; | |
| 60 pipeline_capability_map_.Clear(); | |
|
mmenke
2011/12/02 21:52:10
Whenever we call this, we basically put the pipeli
James Simonsen
2011/12/03 03:16:00
Yeah, I know. :( I debated it for a bit, but decid
mmenke
2011/12/06 15:50:38
Sounds good to me. Just wanted to make sure you w
| |
| 61 for (it = pipeline_capability_map->begin(); | |
| 62 it != pipeline_capability_map->end(); ++it) { | |
| 63 pipeline_capability_map_.Put(it->first, it->second); | |
| 64 } | |
| 65 } | |
| 66 | |
| 51 void HttpServerPropertiesImpl::GetSpdyServerList( | 67 void HttpServerPropertiesImpl::GetSpdyServerList( |
| 52 base::ListValue* spdy_server_list) const { | 68 base::ListValue* spdy_server_list) const { |
| 53 DCHECK(CalledOnValidThread()); | 69 DCHECK(CalledOnValidThread()); |
| 54 DCHECK(spdy_server_list); | 70 DCHECK(spdy_server_list); |
| 55 spdy_server_list->Clear(); | 71 spdy_server_list->Clear(); |
| 56 // Get the list of servers (host/port) that support SPDY. | 72 // Get the list of servers (host/port) that support SPDY. |
| 57 for (SpdyServerHostPortTable::const_iterator it = spdy_servers_table_.begin(); | 73 for (SpdyServerHostPortTable::const_iterator it = spdy_servers_table_.begin(); |
| 58 it != spdy_servers_table_.end(); ++it) { | 74 it != spdy_servers_table_.end(); ++it) { |
| 59 const std::string spdy_server_host_port = it->first; | 75 const std::string spdy_server_host_port = it->first; |
| 60 if (it->second) | 76 if (it->second) |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 87 void HttpServerPropertiesImpl::DisableForcedAlternateProtocol() { | 103 void HttpServerPropertiesImpl::DisableForcedAlternateProtocol() { |
| 88 delete g_forced_alternate_protocol; | 104 delete g_forced_alternate_protocol; |
| 89 g_forced_alternate_protocol = NULL; | 105 g_forced_alternate_protocol = NULL; |
| 90 } | 106 } |
| 91 | 107 |
| 92 void HttpServerPropertiesImpl::Clear() { | 108 void HttpServerPropertiesImpl::Clear() { |
| 93 DCHECK(CalledOnValidThread()); | 109 DCHECK(CalledOnValidThread()); |
| 94 spdy_servers_table_.clear(); | 110 spdy_servers_table_.clear(); |
| 95 alternate_protocol_map_.clear(); | 111 alternate_protocol_map_.clear(); |
| 96 spdy_settings_map_.clear(); | 112 spdy_settings_map_.clear(); |
| 113 pipeline_capability_map_.Clear(); | |
| 97 } | 114 } |
| 98 | 115 |
| 99 bool HttpServerPropertiesImpl::SupportsSpdy( | 116 bool HttpServerPropertiesImpl::SupportsSpdy( |
| 100 const net::HostPortPair& host_port_pair) const { | 117 const net::HostPortPair& host_port_pair) const { |
| 101 DCHECK(CalledOnValidThread()); | 118 DCHECK(CalledOnValidThread()); |
| 102 if (host_port_pair.host().empty()) | 119 if (host_port_pair.host().empty()) |
| 103 return false; | 120 return false; |
| 104 std::string spdy_server = GetFlattenedSpdyServer(host_port_pair); | 121 std::string spdy_server = GetFlattenedSpdyServer(host_port_pair); |
| 105 | 122 |
| 106 SpdyServerHostPortTable::const_iterator spdy_host_port = | 123 SpdyServerHostPortTable::const_iterator spdy_host_port = |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 232 | 249 |
| 233 void HttpServerPropertiesImpl::ClearSpdySettings() { | 250 void HttpServerPropertiesImpl::ClearSpdySettings() { |
| 234 spdy_settings_map_.clear(); | 251 spdy_settings_map_.clear(); |
| 235 } | 252 } |
| 236 | 253 |
| 237 const SpdySettingsMap& | 254 const SpdySettingsMap& |
| 238 HttpServerPropertiesImpl::spdy_settings_map() const { | 255 HttpServerPropertiesImpl::spdy_settings_map() const { |
| 239 return spdy_settings_map_; | 256 return spdy_settings_map_; |
| 240 } | 257 } |
| 241 | 258 |
| 259 HttpPipelinedHost::Capability HttpServerPropertiesImpl::GetPipelineCapability( | |
| 260 const HostPortPair& origin) { | |
| 261 HttpPipelinedHost::Capability capability = HttpPipelinedHost::UNKNOWN; | |
| 262 CachedPipelineCapabilityMap::const_iterator it = | |
| 263 pipeline_capability_map_.Get(origin); | |
| 264 if (it != pipeline_capability_map_.end()) { | |
| 265 capability = it->second; | |
| 266 } | |
| 267 return capability; | |
| 268 } | |
| 269 | |
| 270 void HttpServerPropertiesImpl::SetPipelineCapability( | |
| 271 const HostPortPair& origin, | |
| 272 HttpPipelinedHost::Capability capability) { | |
| 273 CachedPipelineCapabilityMap::iterator it = | |
| 274 pipeline_capability_map_.Peek(origin); | |
| 275 if (it == pipeline_capability_map_.end() || | |
| 276 it->second != HttpPipelinedHost::INCAPABLE) { | |
| 277 pipeline_capability_map_.Put(origin, capability); | |
| 278 } | |
| 279 } | |
| 280 | |
| 281 void HttpServerPropertiesImpl::ClearPipelineCapabilities() { | |
| 282 pipeline_capability_map_.Clear(); | |
| 283 } | |
| 284 | |
| 285 PipelineCapabilityMap | |
| 286 HttpServerPropertiesImpl::GetPipelineCapabilityMap() const { | |
| 287 PipelineCapabilityMap result; | |
| 288 CachedPipelineCapabilityMap::const_iterator it; | |
| 289 for (it = pipeline_capability_map_.begin(); | |
| 290 it != pipeline_capability_map_.end(); ++it) { | |
| 291 result[it->first] = it->second; | |
| 292 } | |
| 293 return result; | |
| 294 } | |
| 295 | |
| 242 } // namespace net | 296 } // namespace net |
| OLD | NEW |