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

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

Issue 7289006: Basic HTTP pipelining support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge Created 9 years, 2 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
« no previous file with comments | « net/http/http_pipelined_host_pool.h ('k') | net/http/http_pipelined_host_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
(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_pool.h"
6
7 #include "base/logging.h"
8 #include "base/stl_util.h"
9 #include "net/http/http_pipelined_host.h"
10 #include "net/http/http_stream_factory_impl.h"
11
12 namespace net {
13
14 HttpPipelinedHostPool::HttpPipelinedHostPool(HttpStreamFactoryImpl* factory)
15 : factory_(factory) {
16 }
17
18 HttpPipelinedHostPool::~HttpPipelinedHostPool() {
19 CHECK(host_map_.empty());
20 }
21
22 HttpPipelinedStream* HttpPipelinedHostPool::CreateStreamOnNewPipeline(
23 const HostPortPair& origin,
24 ClientSocketHandle* connection,
25 const SSLConfig& used_ssl_config,
26 const ProxyInfo& used_proxy_info,
27 const BoundNetLog& net_log,
28 bool was_npn_negotiated) {
29 HttpPipelinedHost* host = GetPipelinedHost(origin, true);
30 return host->CreateStreamOnNewPipeline(connection, used_ssl_config,
31 used_proxy_info, net_log,
32 was_npn_negotiated);
33 }
34
35 HttpPipelinedStream* HttpPipelinedHostPool::CreateStreamOnExistingPipeline(
36 const HostPortPair& origin) {
37 HttpPipelinedHost* host = GetPipelinedHost(origin, false);
38 if (!host) {
39 return NULL;
40 }
41 return host->CreateStreamOnExistingPipeline();
42 }
43
44 bool HttpPipelinedHostPool::IsExistingPipelineAvailableForOrigin(
45 const HostPortPair& origin) {
46 HttpPipelinedHost* host = GetPipelinedHost(origin, false);
47 if (!host) {
48 return false;
49 }
50 return host->IsExistingPipelineAvailable();
51 }
52
53 HttpPipelinedHost* HttpPipelinedHostPool::GetPipelinedHost(
54 const HostPortPair& origin, bool create_if_not_found) {
55 HostMap::iterator it = host_map_.find(origin);
56 if (it != host_map_.end()) {
57 CHECK(it->second);
58 return it->second;
59 } else if (!create_if_not_found) {
60 return NULL;
61 }
62 HttpPipelinedHost* host = new HttpPipelinedHost(this, origin, NULL);
63 host_map_[origin] = host;
64 return host;
65 }
66
67 void HttpPipelinedHostPool::OnHostIdle(HttpPipelinedHost* host) {
68 const HostPortPair& origin = host->origin();
69 CHECK(ContainsKey(host_map_, origin));
70 // TODO(simonjam): We should remember the pipeline state for each host.
71 host_map_.erase(origin);
72 delete host;
73 }
74
75 void HttpPipelinedHostPool::OnHostHasAdditionalCapacity(
76 HttpPipelinedHost* host) {
77 factory_->OnHttpPipelinedHostHasAdditionalCapacity(host->origin());
78 }
79
80 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_pipelined_host_pool.h ('k') | net/http/http_pipelined_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698