Index: net/http/http_pipelined_host_pool.cc |
=================================================================== |
--- net/http/http_pipelined_host_pool.cc (revision 113337) |
+++ net/http/http_pipelined_host_pool.cc (working copy) |
@@ -6,29 +6,31 @@ |
#include "base/logging.h" |
#include "base/stl_util.h" |
-#include "net/http/http_pipelined_host_capability.h" |
#include "net/http/http_pipelined_host_impl.h" |
-#include "net/http/http_server_properties.h" |
namespace net { |
+// TODO(simonjam): Run experiments with different values of this to see what |
+// value is good at avoiding evictions without eating too much memory. Until |
+// then, this is just a bad guess. |
+static const int kNumHostsToRemember = 200; |
+ |
class HttpPipelinedHostImplFactory : public HttpPipelinedHost::Factory { |
public: |
virtual HttpPipelinedHost* CreateNewHost( |
HttpPipelinedHost::Delegate* delegate, const HostPortPair& origin, |
HttpPipelinedConnection::Factory* factory, |
- HttpPipelinedHostCapability capability) OVERRIDE { |
+ HttpPipelinedHost::Capability capability) OVERRIDE { |
return new HttpPipelinedHostImpl(delegate, origin, factory, capability); |
} |
}; |
HttpPipelinedHostPool::HttpPipelinedHostPool( |
Delegate* delegate, |
- HttpPipelinedHost::Factory* factory, |
- HttpServerProperties* http_server_properties) |
+ HttpPipelinedHost::Factory* factory) |
: delegate_(delegate), |
factory_(factory), |
- http_server_properties_(http_server_properties) { |
+ known_capability_map_(kNumHostsToRemember) { |
if (!factory) { |
factory_.reset(new HttpPipelinedHostImplFactory); |
} |
@@ -40,9 +42,8 @@ |
bool HttpPipelinedHostPool::IsHostEligibleForPipelining( |
const HostPortPair& origin) { |
- HttpPipelinedHostCapability capability = |
- http_server_properties_->GetPipelineCapability(origin); |
- return capability != PIPELINE_INCAPABLE; |
+ HttpPipelinedHost::Capability capability = GetHostCapability(origin); |
+ return capability != HttpPipelinedHost::INCAPABLE; |
} |
HttpPipelinedStream* HttpPipelinedHostPool::CreateStreamOnNewPipeline( |
@@ -89,9 +90,8 @@ |
return NULL; |
} |
- HttpPipelinedHostCapability capability = |
- http_server_properties_->GetPipelineCapability(origin); |
- if (capability == PIPELINE_INCAPABLE) { |
+ HttpPipelinedHost::Capability capability = GetHostCapability(origin); |
+ if (capability == HttpPipelinedHost::INCAPABLE) { |
return NULL; |
} |
@@ -115,8 +115,22 @@ |
void HttpPipelinedHostPool::OnHostDeterminedCapability( |
HttpPipelinedHost* host, |
- HttpPipelinedHostCapability capability) { |
- http_server_properties_->SetPipelineCapability(host->origin(), capability); |
+ HttpPipelinedHost::Capability capability) { |
+ CapabilityMap::iterator known_it = known_capability_map_.Get(host->origin()); |
+ if (known_it == known_capability_map_.end() || |
+ known_it->second != HttpPipelinedHost::INCAPABLE) { |
+ known_capability_map_.Put(host->origin(), capability); |
+ } |
} |
+HttpPipelinedHost::Capability HttpPipelinedHostPool::GetHostCapability( |
+ const HostPortPair& origin) { |
+ HttpPipelinedHost::Capability capability = HttpPipelinedHost::UNKNOWN; |
+ CapabilityMap::const_iterator it = known_capability_map_.Get(origin); |
+ if (it != known_capability_map_.end()) { |
+ capability = it->second; |
+ } |
+ return capability; |
+} |
+ |
} // namespace net |