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

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

Issue 7289006: Basic HTTP pipelining support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use HttpStreamFactoryImpl::Job Created 9 years, 5 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "net/http/http_pipelined_host.h"
6
7 #include "base/stl_util-inl.h"
8 #include "net/http/http_pipelined_connection.h"
9 #include "net/http/http_pipelined_host_pool.h"
10 #include "net/http/http_pipelined_stream.h"
11
12 namespace net {
13
14 HttpPipelinedHost::HttpPipelinedHost(HttpPipelinedHostPool* pool,
15 const HostPortPair& origin)
16 : pool_(pool),
17 origin_(origin) {
18 }
19
20 HttpPipelinedHost::~HttpPipelinedHost() {
21 DCHECK(pipelines_.empty());
22 }
23
24 HttpPipelinedConnection* HttpPipelinedHost::CreateNewPipeline(
25 ClientSocketHandle* connection,
26 const SSLConfig& used_ssl_config,
27 const ProxyInfo& used_proxy_info,
28 const BoundNetLog& net_log,
29 bool was_npn_negotiated) {
30 HttpPipelinedConnection* pipeline = new HttpPipelinedConnection(
31 connection, this, used_ssl_config, used_proxy_info, net_log,
32 was_npn_negotiated);
33 pipelines_.insert(pipeline);
34 return pipeline;
35 }
36
37 HttpPipelinedConnection* HttpPipelinedHost::FindAvailablePipeline() {
38 HttpPipelinedConnection* available_pipeline = NULL;
39 for (std::set<HttpPipelinedConnection*>::iterator it = pipelines_.begin();
40 it != pipelines_.end(); ++it) {
41 if ((*it)->usable() &&
42 (*it)->active() &&
43 (*it)->depth() < max_pipeline_depth() &&
44 (!available_pipeline || (*it)->depth() < available_pipeline->depth())) {
45 available_pipeline = *it;
46 }
47 }
48 return available_pipeline;
49 }
50
51 void HttpPipelinedHost::OnPipelineEmpty(HttpPipelinedConnection* pipeline) {
52 DCHECK(ContainsKey(pipelines_, pipeline));
53 pipelines_.erase(pipeline);
54 delete pipeline;
55 if (pipelines_.empty()) {
56 pool_->OnHostIdle(this);
57 // WARNING: We'll probably be deleted here.
58 }
59 }
60
61 void HttpPipelinedHost::OnPipelineHasCapacity(
62 HttpPipelinedConnection* pipeline) {
63 if (pipeline->usable() && pipeline->depth() < max_pipeline_depth()) {
64 pool_->OnHostHasAdditionalCapacity(this);
65 }
66 if (!pipeline->depth()) {
67 OnPipelineEmpty(pipeline);
68 // WARNING: We'll probably be deleted here.
69 }
70 }
71
72 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698