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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: net/http/http_pipelined_host.cc
diff --git a/net/http/http_pipelined_host.cc b/net/http/http_pipelined_host.cc
new file mode 100644
index 0000000000000000000000000000000000000000..958c417cfff7c5c1d6257663fa8f1fa879190ca5
--- /dev/null
+++ b/net/http/http_pipelined_host.cc
@@ -0,0 +1,72 @@
+// 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.h"
+
+#include "base/stl_util-inl.h"
+#include "net/http/http_pipelined_connection.h"
+#include "net/http/http_pipelined_host_pool.h"
+#include "net/http/http_pipelined_stream.h"
+
+namespace net {
+
+HttpPipelinedHost::HttpPipelinedHost(HttpPipelinedHostPool* pool,
+ const HostPortPair& origin)
+ : pool_(pool),
+ origin_(origin) {
+}
+
+HttpPipelinedHost::~HttpPipelinedHost() {
+ DCHECK(pipelines_.empty());
+}
+
+HttpPipelinedConnection* HttpPipelinedHost::CreateNewPipeline(
+ ClientSocketHandle* connection,
+ const SSLConfig& used_ssl_config,
+ const ProxyInfo& used_proxy_info,
+ const BoundNetLog& net_log,
+ bool was_npn_negotiated) {
+ HttpPipelinedConnection* pipeline = new HttpPipelinedConnection(
+ connection, this, used_ssl_config, used_proxy_info, net_log,
+ was_npn_negotiated);
+ pipelines_.insert(pipeline);
+ return pipeline;
+}
+
+HttpPipelinedConnection* HttpPipelinedHost::FindAvailablePipeline() {
+ HttpPipelinedConnection* available_pipeline = NULL;
+ for (std::set<HttpPipelinedConnection*>::iterator it = pipelines_.begin();
+ it != pipelines_.end(); ++it) {
+ if ((*it)->usable() &&
+ (*it)->active() &&
+ (*it)->depth() < max_pipeline_depth() &&
+ (!available_pipeline || (*it)->depth() < available_pipeline->depth())) {
+ available_pipeline = *it;
+ }
+ }
+ return available_pipeline;
+}
+
+void HttpPipelinedHost::OnPipelineEmpty(HttpPipelinedConnection* pipeline) {
+ DCHECK(ContainsKey(pipelines_, pipeline));
+ pipelines_.erase(pipeline);
+ delete pipeline;
+ if (pipelines_.empty()) {
+ pool_->OnHostIdle(this);
+ // WARNING: We'll probably be deleted here.
+ }
+}
+
+void HttpPipelinedHost::OnPipelineHasCapacity(
+ HttpPipelinedConnection* pipeline) {
+ if (pipeline->usable() && pipeline->depth() < max_pipeline_depth()) {
+ pool_->OnHostHasAdditionalCapacity(this);
+ }
+ if (!pipeline->depth()) {
+ OnPipelineEmpty(pipeline);
+ // WARNING: We'll probably be deleted here.
+ }
+}
+
+} // namespace net

Powered by Google App Engine
This is Rietveld 408576698