Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(836)

Side by Side Diff: net/http/http_pipelined_host_pool.cc

Issue 8833003: Revert 113315 (speculative revert for http://crbug.com/106657) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/http/http_pipelined_host_pool.h ('k') | net/http/http_pipelined_host_pool_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_pipelined_host_pool.h" 5 #include "net/http/http_pipelined_host_pool.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "net/http/http_pipelined_host_capability.h"
10 #include "net/http/http_pipelined_host_impl.h" 9 #include "net/http/http_pipelined_host_impl.h"
11 #include "net/http/http_server_properties.h"
12 10
13 namespace net { 11 namespace net {
14 12
13 // TODO(simonjam): Run experiments with different values of this to see what
14 // value is good at avoiding evictions without eating too much memory. Until
15 // then, this is just a bad guess.
16 static const int kNumHostsToRemember = 200;
17
15 class HttpPipelinedHostImplFactory : public HttpPipelinedHost::Factory { 18 class HttpPipelinedHostImplFactory : public HttpPipelinedHost::Factory {
16 public: 19 public:
17 virtual HttpPipelinedHost* CreateNewHost( 20 virtual HttpPipelinedHost* CreateNewHost(
18 HttpPipelinedHost::Delegate* delegate, const HostPortPair& origin, 21 HttpPipelinedHost::Delegate* delegate, const HostPortPair& origin,
19 HttpPipelinedConnection::Factory* factory, 22 HttpPipelinedConnection::Factory* factory,
20 HttpPipelinedHostCapability capability) OVERRIDE { 23 HttpPipelinedHost::Capability capability) OVERRIDE {
21 return new HttpPipelinedHostImpl(delegate, origin, factory, capability); 24 return new HttpPipelinedHostImpl(delegate, origin, factory, capability);
22 } 25 }
23 }; 26 };
24 27
25 HttpPipelinedHostPool::HttpPipelinedHostPool( 28 HttpPipelinedHostPool::HttpPipelinedHostPool(
26 Delegate* delegate, 29 Delegate* delegate,
27 HttpPipelinedHost::Factory* factory, 30 HttpPipelinedHost::Factory* factory)
28 HttpServerProperties* http_server_properties)
29 : delegate_(delegate), 31 : delegate_(delegate),
30 factory_(factory), 32 factory_(factory),
31 http_server_properties_(http_server_properties) { 33 known_capability_map_(kNumHostsToRemember) {
32 if (!factory) { 34 if (!factory) {
33 factory_.reset(new HttpPipelinedHostImplFactory); 35 factory_.reset(new HttpPipelinedHostImplFactory);
34 } 36 }
35 } 37 }
36 38
37 HttpPipelinedHostPool::~HttpPipelinedHostPool() { 39 HttpPipelinedHostPool::~HttpPipelinedHostPool() {
38 CHECK(host_map_.empty()); 40 CHECK(host_map_.empty());
39 } 41 }
40 42
41 bool HttpPipelinedHostPool::IsHostEligibleForPipelining( 43 bool HttpPipelinedHostPool::IsHostEligibleForPipelining(
42 const HostPortPair& origin) { 44 const HostPortPair& origin) {
43 HttpPipelinedHostCapability capability = 45 HttpPipelinedHost::Capability capability = GetHostCapability(origin);
44 http_server_properties_->GetPipelineCapability(origin); 46 return capability != HttpPipelinedHost::INCAPABLE;
45 return capability != PIPELINE_INCAPABLE;
46 } 47 }
47 48
48 HttpPipelinedStream* HttpPipelinedHostPool::CreateStreamOnNewPipeline( 49 HttpPipelinedStream* HttpPipelinedHostPool::CreateStreamOnNewPipeline(
49 const HostPortPair& origin, 50 const HostPortPair& origin,
50 ClientSocketHandle* connection, 51 ClientSocketHandle* connection,
51 const SSLConfig& used_ssl_config, 52 const SSLConfig& used_ssl_config,
52 const ProxyInfo& used_proxy_info, 53 const ProxyInfo& used_proxy_info,
53 const BoundNetLog& net_log, 54 const BoundNetLog& net_log,
54 bool was_npn_negotiated) { 55 bool was_npn_negotiated) {
55 HttpPipelinedHost* host = GetPipelinedHost(origin, true); 56 HttpPipelinedHost* host = GetPipelinedHost(origin, true);
(...skipping 26 matching lines...) Expand all
82 HttpPipelinedHost* HttpPipelinedHostPool::GetPipelinedHost( 83 HttpPipelinedHost* HttpPipelinedHostPool::GetPipelinedHost(
83 const HostPortPair& origin, bool create_if_not_found) { 84 const HostPortPair& origin, bool create_if_not_found) {
84 HostMap::iterator host_it = host_map_.find(origin); 85 HostMap::iterator host_it = host_map_.find(origin);
85 if (host_it != host_map_.end()) { 86 if (host_it != host_map_.end()) {
86 CHECK(host_it->second); 87 CHECK(host_it->second);
87 return host_it->second; 88 return host_it->second;
88 } else if (!create_if_not_found) { 89 } else if (!create_if_not_found) {
89 return NULL; 90 return NULL;
90 } 91 }
91 92
92 HttpPipelinedHostCapability capability = 93 HttpPipelinedHost::Capability capability = GetHostCapability(origin);
93 http_server_properties_->GetPipelineCapability(origin); 94 if (capability == HttpPipelinedHost::INCAPABLE) {
94 if (capability == PIPELINE_INCAPABLE) {
95 return NULL; 95 return NULL;
96 } 96 }
97 97
98 HttpPipelinedHost* host = factory_->CreateNewHost( 98 HttpPipelinedHost* host = factory_->CreateNewHost(
99 this, origin, NULL, capability); 99 this, origin, NULL, capability);
100 host_map_[origin] = host; 100 host_map_[origin] = host;
101 return host; 101 return host;
102 } 102 }
103 103
104 void HttpPipelinedHostPool::OnHostIdle(HttpPipelinedHost* host) { 104 void HttpPipelinedHostPool::OnHostIdle(HttpPipelinedHost* host) {
105 const HostPortPair& origin = host->origin(); 105 const HostPortPair& origin = host->origin();
106 CHECK(ContainsKey(host_map_, origin)); 106 CHECK(ContainsKey(host_map_, origin));
107 host_map_.erase(origin); 107 host_map_.erase(origin);
108 delete host; 108 delete host;
109 } 109 }
110 110
111 void HttpPipelinedHostPool::OnHostHasAdditionalCapacity( 111 void HttpPipelinedHostPool::OnHostHasAdditionalCapacity(
112 HttpPipelinedHost* host) { 112 HttpPipelinedHost* host) {
113 delegate_->OnHttpPipelinedHostHasAdditionalCapacity(host->origin()); 113 delegate_->OnHttpPipelinedHostHasAdditionalCapacity(host->origin());
114 } 114 }
115 115
116 void HttpPipelinedHostPool::OnHostDeterminedCapability( 116 void HttpPipelinedHostPool::OnHostDeterminedCapability(
117 HttpPipelinedHost* host, 117 HttpPipelinedHost* host,
118 HttpPipelinedHostCapability capability) { 118 HttpPipelinedHost::Capability capability) {
119 http_server_properties_->SetPipelineCapability(host->origin(), capability); 119 CapabilityMap::iterator known_it = known_capability_map_.Get(host->origin());
120 if (known_it == known_capability_map_.end() ||
121 known_it->second != HttpPipelinedHost::INCAPABLE) {
122 known_capability_map_.Put(host->origin(), capability);
123 }
124 }
125
126 HttpPipelinedHost::Capability HttpPipelinedHostPool::GetHostCapability(
127 const HostPortPair& origin) {
128 HttpPipelinedHost::Capability capability = HttpPipelinedHost::UNKNOWN;
129 CapabilityMap::const_iterator it = known_capability_map_.Get(origin);
130 if (it != known_capability_map_.end()) {
131 capability = it->second;
132 }
133 return capability;
120 } 134 }
121 135
122 } // namespace net 136 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_pipelined_host_pool.h ('k') | net/http/http_pipelined_host_pool_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698