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

Unified Diff: net/http/http_stream_factory_impl_job.cc

Issue 7289006: Basic HTTP pipelining support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added about:flags entry 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_stream_factory_impl_job.cc
diff --git a/net/http/http_stream_factory_impl_job.cc b/net/http/http_stream_factory_impl_job.cc
index 895266891977b8481f3c0bf0d55bea2426defc39..376c5bf39eef6cd0a6206a96f6a3f76f03c381d2 100644
--- a/net/http/http_stream_factory_impl_job.cc
+++ b/net/http/http_stream_factory_impl_job.cc
@@ -16,9 +16,14 @@
#include "net/base/ssl_cert_request_info.h"
#include "net/http/http_basic_stream.h"
#include "net/http/http_network_session.h"
+#include "net/http/http_pipelined_connection.h"
+#include "net/http/http_pipelined_host.h"
+#include "net/http/http_pipelined_host_pool.h"
+#include "net/http/http_pipelined_stream.h"
#include "net/http/http_proxy_client_socket.h"
#include "net/http/http_proxy_client_socket_pool.h"
#include "net/http/http_request_info.h"
+#include "net/http/http_stream_factory.h"
#include "net/http/http_stream_factory_impl_request.h"
#include "net/socket/client_socket_handle.h"
#include "net/socket/client_socket_pool.h"
@@ -85,6 +90,7 @@ HttpStreamFactoryImpl::Job::Job(HttpStreamFactoryImpl* stream_factory,
was_npn_negotiated_(false),
num_streams_(0),
spdy_session_direct_(false),
+ existing_available_pipeline_(NULL),
ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
DCHECK(stream_factory);
DCHECK(session);
@@ -580,6 +586,18 @@ int HttpStreamFactoryImpl::Job::DoInitConnection() {
} else if (request_ && (using_ssl_ || ShouldForceSpdyWithoutSSL())) {
// Update the spdy session key for the request that launched this job.
request_->SetSpdySessionKey(spdy_session_key);
+ } else if (IsRequestEligibleForPipelining()) {
mmenke 2011/08/03 21:09:39 Looks to me like you're implicitly not using pipel
James Simonsen 2011/08/05 01:39:00 Done.
+ HttpPipelinedHost* host = session_->http_pipelined_host_pool()->
+ GetPipelinedHostIfExists(origin_);
+ if (host) {
+ HttpPipelinedConnection* connection = host->FindAvailablePipeline();
+ if (connection) {
+ next_state_ = STATE_CREATE_STREAM;
+ existing_available_pipeline_ = connection;
+ return OK;
+ }
+ }
+ request_->SetHttpPipeliningKey(origin_);
}
// OK, there's no available SPDY session. Let |dependent_job_| resume if it's
@@ -757,9 +775,13 @@ int HttpStreamFactoryImpl::Job::DoWaitingUserAction(int result) {
}
int HttpStreamFactoryImpl::Job::DoCreateStream() {
- if (!connection_->socket() && !existing_spdy_session_)
+ if (!connection_->socket() && !existing_spdy_session_ &&
+ !existing_available_pipeline_)
HACKCrashHereToDebug80095();
+ DCHECK(connection_->socket() || existing_spdy_session_ ||
+ existing_available_pipeline_);
+
next_state_ = STATE_CREATE_STREAM_COMPLETE;
// We only set the socket motivation if we're the first to use
@@ -773,8 +795,22 @@ int HttpStreamFactoryImpl::Job::DoCreateStream() {
if (!using_spdy_) {
bool using_proxy = (proxy_info_.is_http() || proxy_info_.is_https()) &&
request_info_.url.SchemeIs("http");
- stream_.reset(new HttpBasicStream(connection_.release(), NULL,
- using_proxy));
+ // TODO(simonjam): Support proxies.
+ if (existing_available_pipeline_) {
+ stream_.reset(new HttpPipelinedStream(existing_available_pipeline_));
+ } else if (!using_proxy && IsRequestEligibleForPipelining()) {
+ HttpPipelinedConnection* pipeline = session_->http_pipelined_host_pool()->
+ GetOrCreatePipelinedHost(origin_)->CreateNewPipeline(
+ connection_.release(),
+ ssl_config_,
+ proxy_info_,
+ net_log_,
+ was_npn_negotiated_);
+ stream_.reset(new HttpPipelinedStream(pipeline));
+ } else {
+ stream_.reset(new HttpBasicStream(connection_.release(), NULL,
+ using_proxy));
+ }
return OK;
}
@@ -1073,6 +1109,16 @@ bool HttpStreamFactoryImpl::Job::IsOrphaned() const {
return !IsPreconnecting() && !request_;
}
+bool HttpStreamFactoryImpl::Job::IsRequestEligibleForPipelining() const {
+ if (!HttpStreamFactory::http_pipelining_enabled()) {
+ return false;
+ }
+ if (IsPreconnecting() || !request_) {
+ return false;
+ }
+ return request_info_.method == "GET" || request_info_.method == "HEAD";
+}
+
#if defined(OS_WIN)
#pragma warning (disable: 4748)
#pragma optimize( "", off )

Powered by Google App Engine
This is Rietveld 408576698