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

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

Issue 9433015: Add a force pipelining option to load flags. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: More tests Created 8 years, 10 months 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_impl.h" 5 #include "net/http/http_pipelined_host_impl.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "net/http/http_pipelined_connection_impl.h" 9 #include "net/http/http_pipelined_connection_impl.h"
10 #include "net/http/http_pipelined_stream.h" 10 #include "net/http/http_pipelined_stream.h"
11 11
12 using base::DictionaryValue; 12 using base::DictionaryValue;
13 using base::ListValue; 13 using base::ListValue;
14 using base::Value; 14 using base::Value;
15 15
16 namespace net { 16 namespace net {
17 17
18 // TODO(simonjam): Run experiments to see what value minimizes evictions without 18 // TODO(simonjam): Run experiments to see what value minimizes evictions without
19 // costing too much performance. Until then, this is just a bad guess. 19 // costing too much performance. Until then, this is just a bad guess.
20 static const int kNumKnownSuccessesThreshold = 3; 20 static const int kNumKnownSuccessesThreshold = 3;
21 21
22 class HttpPipelinedConnectionImplFactory :
23 public HttpPipelinedConnection::Factory {
24 public:
25 HttpPipelinedConnection* CreateNewPipeline(
26 ClientSocketHandle* connection,
27 HttpPipelinedConnection::Delegate* delegate,
28 const HostPortPair& origin,
29 const SSLConfig& used_ssl_config,
30 const ProxyInfo& used_proxy_info,
31 const BoundNetLog& net_log,
32 bool was_npn_negotiated,
33 SSLClientSocket::NextProto protocol_negotiated) OVERRIDE {
34 return new HttpPipelinedConnectionImpl(connection, delegate, origin,
35 used_ssl_config, used_proxy_info,
36 net_log, was_npn_negotiated,
37 protocol_negotiated);
38 }
39 };
40
41 HttpPipelinedHostImpl::HttpPipelinedHostImpl( 22 HttpPipelinedHostImpl::HttpPipelinedHostImpl(
42 HttpPipelinedHost::Delegate* delegate, 23 HttpPipelinedHost::Delegate* delegate,
43 const HostPortPair& origin, 24 const HttpPipelinedHost::Key& key,
44 HttpPipelinedConnection::Factory* factory, 25 HttpPipelinedConnection::Factory* factory,
45 HttpPipelinedHostCapability capability) 26 HttpPipelinedHostCapability capability)
46 : delegate_(delegate), 27 : delegate_(delegate),
47 origin_(origin), 28 key_(key),
48 factory_(factory), 29 factory_(factory),
49 capability_(capability) { 30 capability_(capability) {
31 CHECK(!key.force_pipelining());
50 if (!factory) { 32 if (!factory) {
51 factory_.reset(new HttpPipelinedConnectionImplFactory()); 33 factory_.reset(new HttpPipelinedConnectionImpl::Factory());
52 } 34 }
53 } 35 }
54 36
55 HttpPipelinedHostImpl::~HttpPipelinedHostImpl() { 37 HttpPipelinedHostImpl::~HttpPipelinedHostImpl() {
56 CHECK(pipelines_.empty()); 38 CHECK(pipelines_.empty());
57 } 39 }
58 40
59 HttpPipelinedStream* HttpPipelinedHostImpl::CreateStreamOnNewPipeline( 41 HttpPipelinedStream* HttpPipelinedHostImpl::CreateStreamOnNewPipeline(
60 ClientSocketHandle* connection, 42 ClientSocketHandle* connection,
61 const SSLConfig& used_ssl_config, 43 const SSLConfig& used_ssl_config,
62 const ProxyInfo& used_proxy_info, 44 const ProxyInfo& used_proxy_info,
63 const BoundNetLog& net_log, 45 const BoundNetLog& net_log,
64 bool was_npn_negotiated, 46 bool was_npn_negotiated,
65 SSLClientSocket::NextProto protocol_negotiated) { 47 SSLClientSocket::NextProto protocol_negotiated) {
66 if (capability_ == PIPELINE_INCAPABLE) { 48 if (capability_ == PIPELINE_INCAPABLE) {
67 return NULL; 49 return NULL;
68 } 50 }
69 HttpPipelinedConnection* pipeline = factory_->CreateNewPipeline( 51 HttpPipelinedConnection* pipeline = factory_->CreateNewPipeline(
70 connection, this, origin_, used_ssl_config, used_proxy_info, net_log, 52 connection, this, key_.origin(), used_ssl_config, used_proxy_info,
71 was_npn_negotiated, protocol_negotiated); 53 net_log, was_npn_negotiated, protocol_negotiated);
72 PipelineInfo info; 54 PipelineInfo info;
73 pipelines_.insert(std::make_pair(pipeline, info)); 55 pipelines_.insert(std::make_pair(pipeline, info));
74 return pipeline->CreateNewStream(); 56 return pipeline->CreateNewStream();
75 } 57 }
76 58
77 HttpPipelinedStream* HttpPipelinedHostImpl::CreateStreamOnExistingPipeline() { 59 HttpPipelinedStream* HttpPipelinedHostImpl::CreateStreamOnExistingPipeline() {
78 HttpPipelinedConnection* available_pipeline = NULL; 60 HttpPipelinedConnection* available_pipeline = NULL;
79 for (PipelineInfoMap::iterator it = pipelines_.begin(); 61 for (PipelineInfoMap::iterator it = pipelines_.begin();
80 it != pipelines_.end(); ++it) { 62 it != pipelines_.end(); ++it) {
81 if (CanPipelineAcceptRequests(it->first) && 63 if (CanPipelineAcceptRequests(it->first) &&
(...skipping 11 matching lines...) Expand all
93 bool HttpPipelinedHostImpl::IsExistingPipelineAvailable() const { 75 bool HttpPipelinedHostImpl::IsExistingPipelineAvailable() const {
94 for (PipelineInfoMap::const_iterator it = pipelines_.begin(); 76 for (PipelineInfoMap::const_iterator it = pipelines_.begin();
95 it != pipelines_.end(); ++it) { 77 it != pipelines_.end(); ++it) {
96 if (CanPipelineAcceptRequests(it->first)) { 78 if (CanPipelineAcceptRequests(it->first)) {
97 return true; 79 return true;
98 } 80 }
99 } 81 }
100 return false; 82 return false;
101 } 83 }
102 84
103 const HostPortPair& HttpPipelinedHostImpl::origin() const { 85 const HttpPipelinedHost::Key& HttpPipelinedHostImpl::GetKey() const {
104 return origin_; 86 return key_;
105 } 87 }
106 88
107 void HttpPipelinedHostImpl::OnPipelineEmpty(HttpPipelinedConnection* pipeline) { 89 void HttpPipelinedHostImpl::OnPipelineEmpty(HttpPipelinedConnection* pipeline) {
108 CHECK(ContainsKey(pipelines_, pipeline)); 90 CHECK(ContainsKey(pipelines_, pipeline));
109 pipelines_.erase(pipeline); 91 pipelines_.erase(pipeline);
110 delete pipeline; 92 delete pipeline;
111 if (pipelines_.empty()) { 93 if (pipelines_.empty()) {
112 delegate_->OnHostIdle(this); 94 delegate_->OnHostIdle(this);
113 // WARNING: We'll probably be deleted here. 95 // WARNING: We'll probably be deleted here.
114 } 96 }
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 OnPipelineHasCapacity(it->first); 189 OnPipelineHasCapacity(it->first);
208 } 190 }
209 } 191 }
210 } 192 }
211 193
212 Value* HttpPipelinedHostImpl::PipelineInfoToValue() const { 194 Value* HttpPipelinedHostImpl::PipelineInfoToValue() const {
213 ListValue* list_value = new ListValue(); 195 ListValue* list_value = new ListValue();
214 for (PipelineInfoMap::const_iterator it = pipelines_.begin(); 196 for (PipelineInfoMap::const_iterator it = pipelines_.begin();
215 it != pipelines_.end(); ++it) { 197 it != pipelines_.end(); ++it) {
216 DictionaryValue* pipeline_dict = new DictionaryValue; 198 DictionaryValue* pipeline_dict = new DictionaryValue;
217 pipeline_dict->SetString("host", origin_.ToString()); 199 pipeline_dict->SetString("host", key_.origin().ToString());
200 pipeline_dict->SetBoolean("forced", key_.force_pipelining());
218 pipeline_dict->SetInteger("depth", it->first->depth()); 201 pipeline_dict->SetInteger("depth", it->first->depth());
219 pipeline_dict->SetInteger("capacity", GetPipelineCapacity()); 202 pipeline_dict->SetInteger("capacity", GetPipelineCapacity());
220 pipeline_dict->SetBoolean("usable", it->first->usable()); 203 pipeline_dict->SetBoolean("usable", it->first->usable());
221 pipeline_dict->SetBoolean("active", it->first->active()); 204 pipeline_dict->SetBoolean("active", it->first->active());
222 pipeline_dict->SetInteger("source_id", it->first->net_log().source().id); 205 pipeline_dict->SetInteger("source_id", it->first->net_log().source().id);
223 list_value->Append(pipeline_dict); 206 list_value->Append(pipeline_dict);
224 } 207 }
225 return list_value; 208 return list_value;
226 } 209 }
227 210
228 HttpPipelinedHostImpl::PipelineInfo::PipelineInfo() 211 HttpPipelinedHostImpl::PipelineInfo::PipelineInfo()
229 : num_successes(0) { 212 : num_successes(0) {
230 } 213 }
231 214
232 } // namespace net 215 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698