diff options
author | simonjam@chromium.org <simonjam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-19 20:14:29 +0000 |
---|---|---|
committer | simonjam@chromium.org <simonjam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-19 20:14:29 +0000 |
commit | 5a60c8bb002e4573dd0809f4a78d56b4c9720add (patch) | |
tree | 4be91c33213b0e7ab66dfed7ced978e8a16b3cdc /net/http/http_pipelined_host_pool.cc | |
parent | 8053408224c37ade07452972e01de6126d074d27 (diff) | |
download | chromium_src-5a60c8bb002e4573dd0809f4a78d56b4c9720add.zip chromium_src-5a60c8bb002e4573dd0809f4a78d56b4c9720add.tar.gz chromium_src-5a60c8bb002e4573dd0809f4a78d56b4c9720add.tar.bz2 |
Basic HTTP pipelining support.
This must be enabled in about:flags. It is naive and assumes all servers correctly implement pipelining. Proxies are not supported.
Immediate future work:
- Integration tests.
- Additional NetLog logging.
- Refactor HttpPipelinedConnectionImpl.
Long term:
- Detect broken transparent proxies.
- Detect and/or mitigate broken servers.
- Buffer HttpPipelinedStream.
- Optimize number of pipelines and their depth.
- Support proxies.
BUG=8991
TEST=net_unittests
Review URL: http://codereview.chromium.org/7289006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106364 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_pipelined_host_pool.cc')
-rw-r--r-- | net/http/http_pipelined_host_pool.cc | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/net/http/http_pipelined_host_pool.cc b/net/http/http_pipelined_host_pool.cc new file mode 100644 index 0000000..bd238d8 --- /dev/null +++ b/net/http/http_pipelined_host_pool.cc @@ -0,0 +1,80 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "net/http/http_pipelined_host_pool.h" + +#include "base/logging.h" +#include "base/stl_util.h" +#include "net/http/http_pipelined_host.h" +#include "net/http/http_stream_factory_impl.h" + +namespace net { + +HttpPipelinedHostPool::HttpPipelinedHostPool(HttpStreamFactoryImpl* factory) + : factory_(factory) { +} + +HttpPipelinedHostPool::~HttpPipelinedHostPool() { + CHECK(host_map_.empty()); +} + +HttpPipelinedStream* HttpPipelinedHostPool::CreateStreamOnNewPipeline( + const HostPortPair& origin, + ClientSocketHandle* connection, + const SSLConfig& used_ssl_config, + const ProxyInfo& used_proxy_info, + const BoundNetLog& net_log, + bool was_npn_negotiated) { + HttpPipelinedHost* host = GetPipelinedHost(origin, true); + return host->CreateStreamOnNewPipeline(connection, used_ssl_config, + used_proxy_info, net_log, + was_npn_negotiated); +} + +HttpPipelinedStream* HttpPipelinedHostPool::CreateStreamOnExistingPipeline( + const HostPortPair& origin) { + HttpPipelinedHost* host = GetPipelinedHost(origin, false); + if (!host) { + return NULL; + } + return host->CreateStreamOnExistingPipeline(); +} + +bool HttpPipelinedHostPool::IsExistingPipelineAvailableForOrigin( + const HostPortPair& origin) { + HttpPipelinedHost* host = GetPipelinedHost(origin, false); + if (!host) { + return false; + } + return host->IsExistingPipelineAvailable(); +} + +HttpPipelinedHost* HttpPipelinedHostPool::GetPipelinedHost( + const HostPortPair& origin, bool create_if_not_found) { + HostMap::iterator it = host_map_.find(origin); + if (it != host_map_.end()) { + CHECK(it->second); + return it->second; + } else if (!create_if_not_found) { + return NULL; + } + HttpPipelinedHost* host = new HttpPipelinedHost(this, origin, NULL); + host_map_[origin] = host; + return host; +} + +void HttpPipelinedHostPool::OnHostIdle(HttpPipelinedHost* host) { + const HostPortPair& origin = host->origin(); + CHECK(ContainsKey(host_map_, origin)); + // TODO(simonjam): We should remember the pipeline state for each host. + host_map_.erase(origin); + delete host; +} + +void HttpPipelinedHostPool::OnHostHasAdditionalCapacity( + HttpPipelinedHost* host) { + factory_->OnHttpPipelinedHostHasAdditionalCapacity(host->origin()); +} + +} // namespace net |