summaryrefslogtreecommitdiffstats
path: root/net/http
diff options
context:
space:
mode:
authorrch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-16 04:53:25 +0000
committerrch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-16 04:53:25 +0000
commitf1e97e93f49bc2e6b76c7312e87fad2246a1703e (patch)
tree6063fdf12b2df57ebcb8002ef0d6c979c189e470 /net/http
parentf117a4cc7c6cae265071109a9133ff5f853a06f1 (diff)
downloadchromium_src-f1e97e93f49bc2e6b76c7312e87fad2246a1703e.zip
chromium_src-f1e97e93f49bc2e6b76c7312e87fad2246a1703e.tar.gz
chromium_src-f1e97e93f49bc2e6b76c7312e87fad2246a1703e.tar.bz2
Integrating the QuicStreamFactory into the network stack.
Fix static initialized in quic_utils.cc Reverted: 173321 Initially landed: 173311 Review URL: https://chromiumcodereview.appspot.com/11416058 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@173367 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http')
-rw-r--r--net/http/http_network_layer.cc1
-rw-r--r--net/http/http_network_session.cc10
-rw-r--r--net/http/http_network_session.h4
-rw-r--r--net/http/http_stream_factory_impl_job.cc28
-rw-r--r--net/http/http_stream_factory_impl_job.h12
5 files changed, 52 insertions, 3 deletions
diff --git a/net/http/http_network_layer.cc b/net/http/http_network_layer.cc
index 1acc4c0..b7b3048 100644
--- a/net/http/http_network_layer.cc
+++ b/net/http/http_network_layer.cc
@@ -11,6 +11,7 @@
#include "net/http/http_network_session.h"
#include "net/http/http_network_transaction.h"
#include "net/http/http_server_properties_impl.h"
+#include "net/http/http_stream_factory_impl_job.h"
#include "net/spdy/spdy_framer.h"
#include "net/spdy/spdy_session.h"
#include "net/spdy/spdy_session_pool.h"
diff --git a/net/http/http_network_session.cc b/net/http/http_network_session.cc
index daace43..dfc6d95 100644
--- a/net/http/http_network_session.cc
+++ b/net/http/http_network_session.cc
@@ -9,6 +9,7 @@
#include "base/compiler_specific.h"
#include "base/debug/stack_trace.h"
#include "base/logging.h"
+#include "base/rand_util.h"
#include "base/stl_util.h"
#include "base/string_util.h"
#include "base/values.h"
@@ -17,6 +18,8 @@
#include "net/http/http_stream_factory_impl.h"
#include "net/http/url_security_manager.h"
#include "net/proxy/proxy_service.h"
+#include "net/quic/quic_clock.h"
+#include "net/quic/quic_stream_factory.h"
#include "net/socket/client_socket_factory.h"
#include "net/socket/client_socket_pool_manager_impl.h"
#include "net/socket/next_proto.h"
@@ -76,7 +79,8 @@ HttpNetworkSession::Params::Params()
spdy_initial_recv_window_size(0),
spdy_initial_max_concurrent_streams(0),
spdy_max_concurrent_streams_limit(0),
- time_func(&base::TimeTicks::Now) {
+ time_func(&base::TimeTicks::Now),
+ origin_port_to_force_quic_on(0) {
}
// TODO(mbelshe): Move the socket factories into HttpStreamFactory.
@@ -93,6 +97,10 @@ HttpNetworkSession::HttpNetworkSession(const Params& params)
CreateSocketPoolManager(NORMAL_SOCKET_POOL, params)),
websocket_socket_pool_manager_(
CreateSocketPoolManager(WEBSOCKET_SOCKET_POOL, params)),
+ quic_stream_factory_(params.host_resolver,
+ net::ClientSocketFactory::GetDefaultFactory(),
+ base::Bind(&base::RandUint64),
+ new QuicClock()),
spdy_session_pool_(params.host_resolver,
params.ssl_config_service,
params.http_server_properties,
diff --git a/net/http/http_network_session.h b/net/http/http_network_session.h
index d47b5a4..c7f7783 100644
--- a/net/http/http_network_session.h
+++ b/net/http/http_network_session.h
@@ -14,6 +14,7 @@
#include "net/base/ssl_client_auth_cache.h"
#include "net/http/http_auth_cache.h"
#include "net/http/http_stream_factory.h"
+#include "net/quic/quic_stream_factory.h"
#include "net/spdy/spdy_session_pool.h"
namespace base {
@@ -79,6 +80,7 @@ class NET_EXPORT HttpNetworkSession
size_t spdy_max_concurrent_streams_limit;
SpdySessionPool::TimeFunc time_func;
std::string trusted_spdy_proxy;
+ uint16 origin_port_to_force_quic_on;
};
enum SocketPoolType {
@@ -114,6 +116,7 @@ class NET_EXPORT HttpNetworkSession
ProxyService* proxy_service() { return proxy_service_; }
SSLConfigService* ssl_config_service() { return ssl_config_service_; }
SpdySessionPool* spdy_session_pool() { return &spdy_session_pool_; }
+ QuicStreamFactory* quic_stream_factory() { return &quic_stream_factory_; }
HttpAuthHandlerFactory* http_auth_handler_factory() {
return http_auth_handler_factory_;
}
@@ -173,6 +176,7 @@ class NET_EXPORT HttpNetworkSession
SSLClientAuthCache ssl_client_auth_cache_;
scoped_ptr<ClientSocketPoolManager> normal_socket_pool_manager_;
scoped_ptr<ClientSocketPoolManager> websocket_socket_pool_manager_;
+ QuicStreamFactory quic_stream_factory_;
SpdySessionPool spdy_session_pool_;
scoped_ptr<HttpStreamFactory> http_stream_factory_;
std::set<HttpResponseBodyDrainer*> response_drainers_;
diff --git a/net/http/http_stream_factory_impl_job.cc b/net/http/http_stream_factory_impl_job.cc
index ddd5ae6..2208dc4 100644
--- a/net/http/http_stream_factory_impl_job.cc
+++ b/net/http/http_stream_factory_impl_job.cc
@@ -28,6 +28,7 @@
#include "net/http/http_server_properties.h"
#include "net/http/http_stream_factory.h"
#include "net/http/http_stream_factory_impl_request.h"
+#include "net/quic/quic_http_stream.h"
#include "net/socket/client_socket_handle.h"
#include "net/socket/client_socket_pool.h"
#include "net/socket/client_socket_pool_manager.h"
@@ -89,6 +90,8 @@ HttpStreamFactoryImpl::Job::Job(HttpStreamFactoryImpl* stream_factory,
waiting_job_(NULL),
using_ssl_(false),
using_spdy_(false),
+ using_quic_(false),
+ quic_request_(session_->quic_stream_factory()),
force_spdy_always_(HttpStreamFactory::force_spdy_always()),
force_spdy_over_ssl_(HttpStreamFactory::force_spdy_over_ssl()),
spdy_certificate_error_(OK),
@@ -157,7 +160,7 @@ LoadState HttpStreamFactoryImpl::Job::GetLoadState() const {
case STATE_RESOLVE_PROXY_COMPLETE:
return session_->proxy_service()->GetLoadState(pac_request_);
case STATE_CREATE_STREAM_COMPLETE:
- return connection_->GetLoadState();
+ return using_quic_ ? LOAD_STATE_CONNECTING : connection_->GetLoadState();
case STATE_INIT_CONNECTION_COMPLETE:
return LOAD_STATE_SENDING_REQUEST;
default:
@@ -638,6 +641,12 @@ bool HttpStreamFactoryImpl::Job::ShouldForceSpdyWithoutSSL() const {
return rv && !HttpStreamFactory::HasSpdyExclusion(origin_);
}
+bool HttpStreamFactoryImpl::Job::ShouldForceQuic() const {
+ return session_->params().origin_port_to_force_quic_on == origin_.port()
+ && session_->params().origin_port_to_force_quic_on != 0
+ && proxy_info_.is_direct();
+}
+
int HttpStreamFactoryImpl::Job::DoWaitForJob() {
DCHECK(blocking_job_);
next_state_ = STATE_WAIT_FOR_JOB_COMPLETE;
@@ -660,6 +669,12 @@ int HttpStreamFactoryImpl::Job::DoInitConnection() {
using_ssl_ = request_info_.url.SchemeIs("https") || ShouldForceSpdySSL();
using_spdy_ = false;
+ if (ShouldForceQuic()) {
+ next_state_ = STATE_CREATE_STREAM;
+ using_quic_ = true;
+ return OK;
+ }
+
// Check first if we have a spdy session for this group. If so, then go
// straight to using that.
HostPortProxyPair spdy_session_key = GetSpdySessionKey();
@@ -903,7 +918,7 @@ int HttpStreamFactoryImpl::Job::DoWaitingUserAction(int result) {
int HttpStreamFactoryImpl::Job::DoCreateStream() {
DCHECK(connection_->socket() || existing_spdy_session_ ||
- existing_available_pipeline_);
+ existing_available_pipeline_ || using_quic_);
next_state_ = STATE_CREATE_STREAM_COMPLETE;
@@ -915,6 +930,11 @@ int HttpStreamFactoryImpl::Job::DoCreateStream() {
const ProxyServer& proxy_server = proxy_info_.proxy_server();
+ if (using_quic_) {
+ return quic_request_.Request(HostPortProxyPair(origin_, proxy_server),
+ net_log_, io_callback_);
+ }
+
if (!using_spdy_) {
bool using_proxy = (proxy_info_.is_http() || proxy_info_.is_https()) &&
request_info_.url.SchemeIs("http");
@@ -997,6 +1017,10 @@ int HttpStreamFactoryImpl::Job::DoCreateStreamComplete(int result) {
if (result < 0)
return result;
+ if (using_quic_) {
+ stream_ = quic_request_.ReleaseStream();
+ }
+
session_->proxy_service()->ReportSuccess(proxy_info_);
next_state_ = STATE_NONE;
return OK;
diff --git a/net/http/http_stream_factory_impl_job.h b/net/http/http_stream_factory_impl_job.h
index 97f4637..5494097 100644
--- a/net/http/http_stream_factory_impl_job.h
+++ b/net/http/http_stream_factory_impl_job.h
@@ -17,6 +17,7 @@
#include "net/http/http_request_info.h"
#include "net/http/http_stream_factory_impl.h"
#include "net/proxy/proxy_service.h"
+#include "net/quic/quic_stream_factory.h"
#include "net/socket/client_socket_handle.h"
#include "net/socket/ssl_client_socket.h"
@@ -27,6 +28,7 @@ class HttpAuthController;
class HttpNetworkSession;
class HttpStream;
class SpdySessionPool;
+class QuicHttpStream;
// An HttpStreamRequestImpl exists for each stream which is in progress of being
// created for the StreamFactory.
@@ -203,6 +205,9 @@ class HttpStreamFactoryImpl::Job {
// Should we force SPDY to run without SSL for this stream request.
bool ShouldForceSpdyWithoutSSL() const;
+ // Should we force QUIC for this stream request.
+ bool ShouldForceQuic() const;
+
bool IsRequestEligibleForPipelining();
// Record histograms of latency until Connect() completes.
@@ -259,12 +264,19 @@ class HttpStreamFactoryImpl::Job {
// True if this network transaction is using SPDY instead of HTTP.
bool using_spdy_;
+ // True if this network transaction is using QUIC instead of HTTP.
+ bool using_quic_;
+ QuicStreamRequest quic_request_;
+
// Force spdy for all connections.
bool force_spdy_always_;
// Force spdy only for SSL connections.
bool force_spdy_over_ssl_;
+ // Force quic for a specific port.
+ int force_quic_port_;
+
// The certificate error while using SPDY over SSL for insecure URLs.
int spdy_certificate_error_;