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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_pipelined_host_pool.cc
diff --git a/net/http/http_pipelined_host_pool.cc b/net/http/http_pipelined_host_pool.cc
new file mode 100644
index 0000000000000000000000000000000000000000..bd238d85649458a2e3a4f17ce9f1f28840775843
--- /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
« 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