summaryrefslogtreecommitdiffstats
path: root/net/http
diff options
context:
space:
mode:
Diffstat (limited to 'net/http')
-rw-r--r--net/http/http_network_layer.cc3
-rw-r--r--net/http/http_network_session.h7
-rw-r--r--net/http/http_network_transaction.cc133
-rw-r--r--net/http/http_network_transaction.h51
-rw-r--r--net/http/http_network_transaction_unittest.cc177
5 files changed, 175 insertions, 196 deletions
diff --git a/net/http/http_network_layer.cc b/net/http/http_network_layer.cc
index 6c905e7..b46012f 100644
--- a/net/http/http_network_layer.cc
+++ b/net/http/http_network_layer.cc
@@ -66,7 +66,8 @@ void HttpNetworkLayer::Suspend(bool suspend) {
HttpNetworkSession* HttpNetworkLayer::GetSession() {
if (!session_) {
DCHECK(proxy_service_);
- session_ = new HttpNetworkSession(proxy_service_);
+ session_ = new HttpNetworkSession(proxy_service_,
+ ClientSocketFactory::GetDefaultFactory());
}
return session_;
}
diff --git a/net/http/http_network_session.h b/net/http/http_network_session.h
index 7c4ac68..d96255a 100644
--- a/net/http/http_network_session.h
+++ b/net/http/http_network_session.h
@@ -12,13 +12,16 @@
namespace net {
+class ClientSocketFactory;
class ProxyService;
// This class holds session objects used by HttpNetworkTransaction objects.
class HttpNetworkSession : public base::RefCounted<HttpNetworkSession> {
public:
- explicit HttpNetworkSession(ProxyService* proxy_service)
- : connection_pool_(new ClientSocketPool(max_sockets_per_group_)),
+ HttpNetworkSession(ProxyService* proxy_service,
+ ClientSocketFactory* client_socket_factory)
+ : connection_pool_(new ClientSocketPool(
+ max_sockets_per_group_, client_socket_factory)),
proxy_service_(proxy_service) {
DCHECK(proxy_service);
}
diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc
index 99a02ba..159d07e 100644
--- a/net/http/http_network_transaction.cc
+++ b/net/http/http_network_transaction.cc
@@ -182,7 +182,7 @@ int HttpNetworkTransaction::RestartIgnoringLastError(
if (connection_.socket()->IsConnected()) {
next_state_ = STATE_WRITE_HEADERS;
} else {
- connection_.set_socket(NULL);
+ connection_.socket()->Disconnect();
connection_.Reset();
next_state_ = STATE_INIT_CONNECTION;
}
@@ -306,7 +306,7 @@ void HttpNetworkTransaction::DidDrainBodyForAuthRestart(bool keep_alive) {
reused_socket_ = true;
} else {
next_state_ = STATE_INIT_CONNECTION;
- connection_.set_socket(NULL);
+ connection_.socket()->Disconnect();
connection_.Reset();
}
@@ -356,10 +356,8 @@ LoadState HttpNetworkTransaction::GetLoadState() const {
switch (next_state_) {
case STATE_RESOLVE_PROXY_COMPLETE:
return LOAD_STATE_RESOLVING_PROXY_FOR_URL;
- case STATE_RESOLVE_HOST_COMPLETE:
- return LOAD_STATE_RESOLVING_HOST;
- case STATE_TCP_CONNECT_COMPLETE:
- return LOAD_STATE_CONNECTING;
+ case STATE_INIT_CONNECTION_COMPLETE:
+ return connection_.GetLoadState();
case STATE_WRITE_HEADERS_COMPLETE:
case STATE_WRITE_BODY_COMPLETE:
return LOAD_STATE_SENDING_REQUEST;
@@ -380,10 +378,10 @@ uint64 HttpNetworkTransaction::GetUploadProgress() const {
}
HttpNetworkTransaction::~HttpNetworkTransaction() {
- // If we still have an open socket, then make sure to close it so we don't
- // try to reuse it later on.
+ // If we still have an open socket, then make sure to disconnect it so we
+ // don't try to reuse it later on.
if (connection_.is_initialized())
- connection_.set_socket(NULL);
+ connection_.socket()->Disconnect();
if (pac_request_)
session_->proxy_service()->CancelPacRequest(pac_request_);
@@ -431,24 +429,6 @@ int HttpNetworkTransaction::DoLoop(int result) {
rv = DoInitConnectionComplete(rv);
TRACE_EVENT_END("http.init_conn", request_, request_->url.spec());
break;
- case STATE_RESOLVE_HOST:
- DCHECK_EQ(OK, rv);
- TRACE_EVENT_BEGIN("http.resolve_host", request_, request_->url.spec());
- rv = DoResolveHost();
- break;
- case STATE_RESOLVE_HOST_COMPLETE:
- rv = DoResolveHostComplete(rv);
- TRACE_EVENT_END("http.resolve_host", request_, request_->url.spec());
- break;
- case STATE_TCP_CONNECT:
- DCHECK_EQ(OK, rv);
- TRACE_EVENT_BEGIN("http.connect", request_, request_->url.spec());
- rv = DoTCPConnect();
- break;
- case STATE_TCP_CONNECT_COMPLETE:
- rv = DoTCPConnectComplete(rv);
- TRACE_EVENT_END("http.connect", request_, request_->url.spec());
- break;
case STATE_SSL_CONNECT:
DCHECK_EQ(OK, rv);
TRACE_EVENT_BEGIN("http.ssl_connect", request_, request_->url.spec());
@@ -558,83 +538,41 @@ int HttpNetworkTransaction::DoInitConnection() {
// Build the string used to uniquely identify connections of this type.
std::string connection_group;
- if (using_proxy_ || using_tunnel_)
- connection_group = "proxy/" + proxy_info_.proxy_server().ToURI() + "/";
+ std::string host;
+ int port;
+ if (using_proxy_ || using_tunnel_) {
+ ProxyServer proxy_server = proxy_info_.proxy_server();
+ connection_group = "proxy/" + proxy_server.ToURI() + "/";
+ host = proxy_server.HostNoBrackets();
+ port = proxy_server.port();
+ } else {
+ host = request_->url.HostNoBrackets();
+ port = request_->url.EffectiveIntPort();
+ }
if (!using_proxy_)
connection_group.append(request_->url.GetOrigin().spec());
DCHECK(!connection_group.empty());
- return connection_.Init(connection_group, request_->priority, &io_callback_);
+ int rv = connection_.Init(connection_group, host, port, request_->priority,
+ &io_callback_);
+ return rv;
}
int HttpNetworkTransaction::DoInitConnectionComplete(int result) {
if (result < 0)
- return result;
+ return ReconsiderProxyAfterError(result);
DCHECK(connection_.is_initialized());
// Set the reused_socket_ flag to indicate that we are using a keep-alive
// connection. This flag is used to handle errors that occur while we are
// trying to reuse a keep-alive connection.
- reused_socket_ = (connection_.socket() != NULL);
+ reused_socket_ = connection_.is_reused();
if (reused_socket_) {
next_state_ = STATE_WRITE_HEADERS;
} else {
- next_state_ = STATE_RESOLVE_HOST;
- }
- return OK;
-}
-
-int HttpNetworkTransaction::DoResolveHost() {
- next_state_ = STATE_RESOLVE_HOST_COMPLETE;
-
- std::string host;
- int port;
-
- // Determine the host and port to connect to.
- if (using_proxy_ || using_tunnel_) {
- ProxyServer proxy_server = proxy_info_.proxy_server();
- host = proxy_server.HostNoBrackets();
- port = proxy_server.port();
- } else {
- // Direct connection
- host = request_->url.HostNoBrackets();
- port = request_->url.EffectiveIntPort();
- }
-
- host_resolution_start_time_ = base::Time::Now();
-
- DidStartDnsResolution(host, this);
- return resolver_.Resolve(host, port, &addresses_, &io_callback_);
-}
-
-int HttpNetworkTransaction::DoResolveHostComplete(int result) {
- bool ok = (result == OK);
- DidFinishDnsResolutionWithStatus(ok, request_->referrer, this);
- if (ok) {
- next_state_ = STATE_TCP_CONNECT;
- } else {
- result = ReconsiderProxyAfterError(result);
- }
- return result;
-}
-
-int HttpNetworkTransaction::DoTCPConnect() {
- next_state_ = STATE_TCP_CONNECT_COMPLETE;
-
- DCHECK(!connection_.socket());
-
- connect_start_time_ = base::Time::Now();
-
- ClientSocket* s = socket_factory_->CreateTCPClientSocket(addresses_);
- connection_.set_socket(s);
- return connection_.socket()->Connect(&io_callback_);
-}
-
-int HttpNetworkTransaction::DoTCPConnectComplete(int result) {
- // If we are using a direct SSL connection, then go ahead and establish the
- // SSL connection, now. Otherwise, we need to first issue a CONNECT request.
- if (result == OK) {
+ // Now we have a TCP connected socket. Perform other connection setup as
+ // needed.
LogTCPConnectedMetrics();
if (using_ssl_ && !using_tunnel_) {
next_state_ = STATE_SSL_CONNECT;
@@ -643,10 +581,8 @@ int HttpNetworkTransaction::DoTCPConnectComplete(int result) {
if (using_tunnel_)
establishing_tunnel_ = true;
}
- } else {
- result = ReconsiderProxyAfterError(result);
}
- return result;
+ return OK;
}
int HttpNetworkTransaction::DoSSLConnect() {
@@ -947,7 +883,7 @@ int HttpNetworkTransaction::DoReadBodyComplete(int result) {
if (done) {
LogTransactionMetrics();
if (!keep_alive)
- connection_.set_socket(NULL);
+ connection_.socket()->Disconnect();
connection_.Reset();
// The next Read call will return 0 (EOF).
}
@@ -1019,15 +955,6 @@ int HttpNetworkTransaction::DoDrainBodyForAuthRestartComplete(int result) {
}
void HttpNetworkTransaction::LogTCPConnectedMetrics() const {
- DCHECK(connect_start_time_ != base::Time());
- base::TimeDelta connect_duration =
- base::Time::Now() - connect_start_time_;
-
- UMA_HISTOGRAM_CLIPPED_TIMES(FieldTrial::MakeName(
- "Net.TCP_Connection_Latency", "DnsImpact").data(), connect_duration,
- base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMinutes(10),
- 100);
-
base::TimeDelta host_resolution_and_tcp_connection_latency =
base::Time::Now() - host_resolution_start_time_;
@@ -1300,7 +1227,7 @@ int HttpNetworkTransaction::HandleSSLHandshakeError(int error) {
// This could be a TLS-intolerant server or an SSL 3.0 server that
// chose a TLS-only cipher suite. Turn off TLS 1.0 and retry.
ssl_config_.tls1_enabled = false;
- connection_.set_socket(NULL);
+ connection_.socket()->Disconnect();
connection_.Reset();
next_state_ = STATE_INIT_CONNECTION;
error = OK;
@@ -1363,7 +1290,7 @@ bool HttpNetworkTransaction::ShouldResendRequest() const {
}
void HttpNetworkTransaction::ResetConnectionAndRequestForResend() {
- connection_.set_socket(NULL);
+ connection_.socket()->Disconnect();
connection_.Reset();
// There are two reasons we need to clear request_headers_. 1) It contains
// the real request headers, but we may need to resend the CONNECT request
@@ -1408,7 +1335,7 @@ int HttpNetworkTransaction::ReconsiderProxyAfterError(int error) {
int rv = session_->proxy_service()->ReconsiderProxyAfterError(
request_->url, &proxy_info_, &io_callback_, &pac_request_);
if (rv == OK || rv == ERR_IO_PENDING) {
- connection_.set_socket(NULL);
+ connection_.socket()->Disconnect();
connection_.Reset();
DCHECK(!request_headers_bytes_sent_);
next_state_ = STATE_RESOLVE_PROXY_COMPLETE;
diff --git a/net/http/http_network_transaction.h b/net/http/http_network_transaction.h
index 291091a..e20239e 100644
--- a/net/http/http_network_transaction.h
+++ b/net/http/http_network_transaction.h
@@ -12,7 +12,10 @@
#include "base/time.h"
#include "net/base/address_list.h"
#include "net/base/client_socket_handle.h"
+#include "net/base/client_socket_pool.h"
#include "net/base/host_resolver.h"
+#include "net/base/load_flags.h"
+#include "net/base/load_states.h"
#include "net/base/ssl_config_service.h"
#include "net/http/http_auth.h"
#include "net/http/http_auth_handler.h"
@@ -87,6 +90,26 @@ class HttpNetworkTransaction : public HttpTransaction {
scoped_ptr_malloc<char> headers_;
};
+ enum State {
+ STATE_RESOLVE_PROXY,
+ STATE_RESOLVE_PROXY_COMPLETE,
+ STATE_INIT_CONNECTION,
+ STATE_INIT_CONNECTION_COMPLETE,
+ STATE_SSL_CONNECT,
+ STATE_SSL_CONNECT_COMPLETE,
+ STATE_WRITE_HEADERS,
+ STATE_WRITE_HEADERS_COMPLETE,
+ STATE_WRITE_BODY,
+ STATE_WRITE_BODY_COMPLETE,
+ STATE_READ_HEADERS,
+ STATE_READ_HEADERS_COMPLETE,
+ STATE_READ_BODY,
+ STATE_READ_BODY_COMPLETE,
+ STATE_DRAIN_BODY_FOR_AUTH_RESTART,
+ STATE_DRAIN_BODY_FOR_AUTH_RESTART_COMPLETE,
+ STATE_NONE
+ };
+
void DoCallback(int result);
void OnIOComplete(int result);
@@ -101,10 +124,6 @@ class HttpNetworkTransaction : public HttpTransaction {
int DoResolveProxyComplete(int result);
int DoInitConnection();
int DoInitConnectionComplete(int result);
- int DoResolveHost();
- int DoResolveHostComplete(int result);
- int DoTCPConnect();
- int DoTCPConnectComplete(int result);
int DoSSLConnect();
int DoSSLConnectComplete(int result);
int DoWriteHeaders();
@@ -362,29 +381,7 @@ class HttpNetworkTransaction : public HttpTransaction {
// The time the host resolution started (if it indeed got started).
base::Time host_resolution_start_time_;
- enum State {
- STATE_RESOLVE_PROXY,
- STATE_RESOLVE_PROXY_COMPLETE,
- STATE_INIT_CONNECTION,
- STATE_INIT_CONNECTION_COMPLETE,
- STATE_RESOLVE_HOST,
- STATE_RESOLVE_HOST_COMPLETE,
- STATE_TCP_CONNECT,
- STATE_TCP_CONNECT_COMPLETE,
- STATE_SSL_CONNECT,
- STATE_SSL_CONNECT_COMPLETE,
- STATE_WRITE_HEADERS,
- STATE_WRITE_HEADERS_COMPLETE,
- STATE_WRITE_BODY,
- STATE_WRITE_BODY_COMPLETE,
- STATE_READ_HEADERS,
- STATE_READ_HEADERS_COMPLETE,
- STATE_READ_BODY,
- STATE_READ_BODY_COMPLETE,
- STATE_DRAIN_BODY_FOR_AUTH_RESTART,
- STATE_DRAIN_BODY_FOR_AUTH_RESTART_COMPLETE,
- STATE_NONE
- };
+ // The next state in the state machine.
State next_state_;
};
diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc
index 007f0fb..c18fa4d 100644
--- a/net/http/http_network_transaction_unittest.cc
+++ b/net/http/http_network_transaction_unittest.cc
@@ -351,8 +351,9 @@ ProxyService* CreateFixedProxyService(const std::string& proxy) {
}
-HttpNetworkSession* CreateSession(ProxyService* proxy_service) {
- return new HttpNetworkSession(proxy_service);
+HttpNetworkSession* CreateSession(ProxyService* proxy_service,
+ ClientSocketFactory* client_socket_factory) {
+ return new HttpNetworkSession(proxy_service, client_socket_factory);
}
class HttpNetworkTransactionTest : public PlatformTest {
@@ -384,8 +385,10 @@ SimpleGetHelperResult SimpleGetHelper(MockRead data_reads[]) {
SimpleGetHelperResult out;
scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
- scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
- CreateSession(proxy_service.get()), &mock_socket_factory));
+ scoped_ptr<HttpTransaction> trans(
+ new HttpNetworkTransaction(
+ CreateSession(proxy_service.get(), &mock_socket_factory),
+ &mock_socket_factory));
HttpRequestInfo request;
request.method = "GET";
@@ -466,8 +469,10 @@ std::string MockGetHostName() {
TEST_F(HttpNetworkTransactionTest, Basic) {
scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
- scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
- CreateSession(proxy_service.get()), &mock_socket_factory));
+ scoped_ptr<HttpTransaction> trans(
+ new HttpNetworkTransaction(
+ CreateSession(proxy_service.get(), &mock_socket_factory),
+ &mock_socket_factory));
}
TEST_F(HttpNetworkTransactionTest, SimpleGET) {
@@ -577,8 +582,10 @@ TEST_F(HttpNetworkTransactionTest, StopsReading204) {
// message body (since HEAD has none).
TEST_F(HttpNetworkTransactionTest, Head) {
scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
- scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
- CreateSession(proxy_service.get()), &mock_socket_factory));
+ scoped_ptr<HttpTransaction> trans(
+ new HttpNetworkTransaction(
+ CreateSession(proxy_service.get(), &mock_socket_factory),
+ &mock_socket_factory));
HttpRequestInfo request;
request.method = "HEAD";
@@ -640,7 +647,7 @@ TEST_F(HttpNetworkTransactionTest, Head) {
TEST_F(HttpNetworkTransactionTest, ReuseConnection) {
scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
scoped_refptr<HttpNetworkSession> session =
- CreateSession(proxy_service.get());
+ CreateSession(proxy_service.get(), &mock_socket_factory);
MockRead data_reads[] = {
MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"),
@@ -690,8 +697,10 @@ TEST_F(HttpNetworkTransactionTest, ReuseConnection) {
TEST_F(HttpNetworkTransactionTest, Ignores100) {
scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
- scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
- CreateSession(proxy_service.get()), &mock_socket_factory));
+ scoped_ptr<HttpTransaction> trans(
+ new HttpNetworkTransaction(
+ CreateSession(proxy_service.get(), &mock_socket_factory),
+ &mock_socket_factory));
HttpRequestInfo request;
request.method = "POST";
@@ -736,8 +745,10 @@ TEST_F(HttpNetworkTransactionTest, Ignores100) {
// HTTP/1.1.
TEST_F(HttpNetworkTransactionTest, Ignores1xx) {
scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
- scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
- CreateSession(proxy_service.get()), &mock_socket_factory));
+ scoped_ptr<HttpTransaction> trans(
+ new HttpNetworkTransaction(
+ CreateSession(proxy_service.get(), &mock_socket_factory),
+ &mock_socket_factory));
HttpRequestInfo request;
request.method = "GET";
@@ -781,7 +792,7 @@ void HttpNetworkTransactionTest::KeepAliveConnectionResendRequestTest(
const MockRead& read_failure) {
scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
scoped_refptr<HttpNetworkSession> session =
- CreateSession(proxy_service.get());
+ CreateSession(proxy_service.get(), &mock_socket_factory);
HttpRequestInfo request;
request.method = "GET";
@@ -847,8 +858,10 @@ TEST_F(HttpNetworkTransactionTest, KeepAliveConnectionEOF) {
TEST_F(HttpNetworkTransactionTest, NonKeepAliveConnectionReset) {
scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
- scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
- CreateSession(proxy_service.get()), &mock_socket_factory));
+ scoped_ptr<HttpTransaction> trans(
+ new HttpNetworkTransaction(
+ CreateSession(proxy_service.get(), &mock_socket_factory),
+ &mock_socket_factory));
HttpRequestInfo request;
request.method = "GET";
@@ -902,8 +915,10 @@ TEST_F(HttpNetworkTransactionTest, NonKeepAliveConnectionEOF) {
// (basic auth is the easiest to mock, because it has no randomness).
TEST_F(HttpNetworkTransactionTest, BasicAuth) {
scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
- scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
- CreateSession(proxy_service.get()), &mock_socket_factory));
+ scoped_ptr<HttpTransaction> trans(
+ new HttpNetworkTransaction(
+ CreateSession(proxy_service.get(), &mock_socket_factory),
+ &mock_socket_factory));
HttpRequestInfo request;
request.method = "GET";
@@ -993,8 +1008,10 @@ TEST_F(HttpNetworkTransactionTest, BasicAuth) {
// connection.
TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAlive) {
scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
- scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
- CreateSession(proxy_service.get()), &mock_socket_factory));
+ scoped_ptr<HttpTransaction> trans(
+ new HttpNetworkTransaction(
+ CreateSession(proxy_service.get(), &mock_socket_factory),
+ &mock_socket_factory));
HttpRequestInfo request;
request.method = "GET";
@@ -1071,8 +1088,10 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAlive) {
// connection and with no response body to drain.
TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAliveNoBody) {
scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
- scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
- CreateSession(proxy_service.get()), &mock_socket_factory));
+ scoped_ptr<HttpTransaction> trans(
+ new HttpNetworkTransaction(
+ CreateSession(proxy_service.get(), &mock_socket_factory),
+ &mock_socket_factory));
HttpRequestInfo request;
request.method = "GET";
@@ -1152,8 +1171,10 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAliveNoBody) {
// connection and with a large response body to drain.
TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAliveLargeBody) {
scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
- scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
- CreateSession(proxy_service.get()), &mock_socket_factory));
+ scoped_ptr<HttpTransaction> trans(
+ new HttpNetworkTransaction(
+ CreateSession(proxy_service.get(), &mock_socket_factory),
+ &mock_socket_factory));
HttpRequestInfo request;
request.method = "GET";
@@ -1240,7 +1261,7 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthProxyKeepAlive) {
CreateFixedProxyService("myproxy:70"));
scoped_refptr<HttpNetworkSession> session(
- CreateSession(proxy_service.get()));
+ CreateSession(proxy_service.get(), &mock_socket_factory));
scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
session.get(), &mock_socket_factory));
@@ -1343,7 +1364,7 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthProxyCancelTunnel) {
CreateFixedProxyService("myproxy:70"));
scoped_refptr<HttpNetworkSession> session(
- CreateSession(proxy_service.get()));
+ CreateSession(proxy_service.get(), &mock_socket_factory));
scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
session.get(), &mock_socket_factory));
@@ -1401,7 +1422,7 @@ static void ConnectStatusHelperWithExpectedStatus(
CreateFixedProxyService("myproxy:70"));
scoped_refptr<HttpNetworkSession> session(
- CreateSession(proxy_service.get()));
+ CreateSession(proxy_service.get(), &mock_socket_factory));
scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
session.get(), &mock_socket_factory));
@@ -1617,7 +1638,7 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthProxyThenServer) {
// Configure against proxy server "myproxy:70".
scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
- CreateSession(proxy_service.get()),
+ CreateSession(proxy_service.get(), &mock_socket_factory),
&mock_socket_factory));
HttpRequestInfo request;
@@ -1756,8 +1777,10 @@ TEST_F(HttpNetworkTransactionTest, NTLMAuth1) {
MockGetHostName);
scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
- scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
- CreateSession(proxy_service.get()), &mock_socket_factory));
+ scoped_ptr<HttpTransaction> trans(
+ new HttpNetworkTransaction(
+ CreateSession(proxy_service.get(), &mock_socket_factory),
+ &mock_socket_factory));
HttpRequestInfo request;
request.method = "GET";
@@ -1884,8 +1907,10 @@ TEST_F(HttpNetworkTransactionTest, NTLMAuth2) {
MockGetHostName);
scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
- scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
- CreateSession(proxy_service.get()), &mock_socket_factory));
+ scoped_ptr<HttpTransaction> trans(
+ new HttpNetworkTransaction(
+ CreateSession(proxy_service.get(), &mock_socket_factory),
+ &mock_socket_factory));
HttpRequestInfo request;
request.method = "GET";
@@ -2093,8 +2118,10 @@ TEST_F(HttpNetworkTransactionTest, NTLMAuth2) {
// fail with ERR_RESPONSE_HEADERS_TOO_BIG.
TEST_F(HttpNetworkTransactionTest, LargeHeadersNoBody) {
scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
- scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
- CreateSession(proxy_service.get()), &mock_socket_factory));
+ scoped_ptr<HttpTransaction> trans(
+ new HttpNetworkTransaction(
+ CreateSession(proxy_service.get(), &mock_socket_factory),
+ &mock_socket_factory));
HttpRequestInfo request;
request.method = "GET";
@@ -2137,7 +2164,7 @@ TEST_F(HttpNetworkTransactionTest, DontRecycleTCPSocketForSSLTunnel) {
CreateFixedProxyService("myproxy:70"));
scoped_refptr<HttpNetworkSession> session(
- CreateSession(proxy_service.get()));
+ CreateSession(proxy_service.get(), &mock_socket_factory));
scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
session.get(), &mock_socket_factory));
@@ -2196,7 +2223,7 @@ TEST_F(HttpNetworkTransactionTest, DontRecycleTCPSocketForSSLTunnel) {
TEST_F(HttpNetworkTransactionTest, RecycleSocket) {
scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
scoped_refptr<HttpNetworkSession> session(
- CreateSession(proxy_service.get()));
+ CreateSession(proxy_service.get(), &mock_socket_factory));
scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
session.get(), &mock_socket_factory));
@@ -2256,7 +2283,7 @@ TEST_F(HttpNetworkTransactionTest, RecycleSocket) {
TEST_F(HttpNetworkTransactionTest, RecycleSocketAfterZeroContentLength) {
scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
scoped_refptr<HttpNetworkSession> session(
- CreateSession(proxy_service.get()));
+ CreateSession(proxy_service.get(), &mock_socket_factory));
scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
session.get(), &mock_socket_factory));
@@ -2331,7 +2358,7 @@ TEST_F(HttpNetworkTransactionTest, ResendRequestOnWriteBodyError) {
scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
scoped_refptr<HttpNetworkSession> session =
- CreateSession(proxy_service.get());
+ CreateSession(proxy_service.get(), &mock_socket_factory);
// The first socket is used for transaction 1 and the first attempt of
// transaction 2.
@@ -2408,8 +2435,10 @@ TEST_F(HttpNetworkTransactionTest, ResendRequestOnWriteBodyError) {
// it fails the identity from the URL is used to answer the challenge.
TEST_F(HttpNetworkTransactionTest, AuthIdentityInUrl) {
scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
- scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
- CreateSession(proxy_service.get()), &mock_socket_factory));
+ scoped_ptr<HttpTransaction> trans(
+ new HttpNetworkTransaction(
+ CreateSession(proxy_service.get(), &mock_socket_factory),
+ &mock_socket_factory));
HttpRequestInfo request;
request.method = "GET";
@@ -2487,7 +2516,7 @@ TEST_F(HttpNetworkTransactionTest, AuthIdentityInUrl) {
TEST_F(HttpNetworkTransactionTest, BasicAuthCacheAndPreauth) {
scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
scoped_refptr<HttpNetworkSession> session =
- CreateSession(proxy_service.get());
+ CreateSession(proxy_service.get(), &mock_socket_factory);
// Transaction 1: authenticate (foo, bar) on MyRealm1
{
@@ -2908,8 +2937,10 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthCacheAndPreauth) {
TEST_F(HttpNetworkTransactionTest, ResetStateForRestart) {
// Create a transaction (the dependencies aren't important).
scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
- scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(
- CreateSession(proxy_service.get()), &mock_socket_factory));
+ scoped_ptr<HttpNetworkTransaction> trans(
+ new HttpNetworkTransaction(
+ CreateSession(proxy_service.get(), &mock_socket_factory),
+ &mock_socket_factory));
// Setup some state (which we expect ResetStateForRestart() will clear).
trans->header_buf_->Realloc(10);
@@ -2966,8 +2997,10 @@ TEST_F(HttpNetworkTransactionTest, ResetStateForRestart) {
// Test HTTPS connections to a site with a bad certificate
TEST_F(HttpNetworkTransactionTest, HTTPSBadCertificate) {
scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
- scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
- CreateSession(proxy_service.get()), &mock_socket_factory));
+ scoped_ptr<HttpTransaction> trans(
+ new HttpNetworkTransaction(
+ CreateSession(proxy_service.get(), &mock_socket_factory),
+ &mock_socket_factory));
HttpRequestInfo request;
request.method = "GET";
@@ -3076,8 +3109,10 @@ TEST_F(HttpNetworkTransactionTest, HTTPSBadCertificateViaProxy) {
mock_sockets_index = 0;
mock_ssl_sockets_index = 0;
- scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
- CreateSession(proxy_service.get()), &mock_socket_factory));
+ scoped_ptr<HttpTransaction> trans(
+ new HttpNetworkTransaction(
+ CreateSession(proxy_service.get(), &mock_socket_factory),
+ &mock_socket_factory));
int rv = trans->Start(&request, &callback);
EXPECT_EQ(ERR_IO_PENDING, rv);
@@ -3100,8 +3135,10 @@ TEST_F(HttpNetworkTransactionTest, HTTPSBadCertificateViaProxy) {
TEST_F(HttpNetworkTransactionTest, BuildRequest_UserAgent) {
scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
- scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
- CreateSession(proxy_service.get()), &mock_socket_factory));
+ scoped_ptr<HttpTransaction> trans(
+ new HttpNetworkTransaction(
+ CreateSession(proxy_service.get(), &mock_socket_factory),
+ &mock_socket_factory));
HttpRequestInfo request;
request.method = "GET";
@@ -3140,8 +3177,10 @@ TEST_F(HttpNetworkTransactionTest, BuildRequest_UserAgent) {
TEST_F(HttpNetworkTransactionTest, BuildRequest_Referer) {
scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
- scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
- CreateSession(proxy_service.get()), &mock_socket_factory));
+ scoped_ptr<HttpTransaction> trans(
+ new HttpNetworkTransaction(
+ CreateSession(proxy_service.get(), &mock_socket_factory),
+ &mock_socket_factory));
HttpRequestInfo request;
request.method = "GET";
@@ -3181,8 +3220,10 @@ TEST_F(HttpNetworkTransactionTest, BuildRequest_Referer) {
TEST_F(HttpNetworkTransactionTest, BuildRequest_PostContentLengthZero) {
scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
- scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
- CreateSession(proxy_service.get()), &mock_socket_factory));
+ scoped_ptr<HttpTransaction> trans(
+ new HttpNetworkTransaction(
+ CreateSession(proxy_service.get(), &mock_socket_factory),
+ &mock_socket_factory));
HttpRequestInfo request;
request.method = "POST";
@@ -3220,8 +3261,10 @@ TEST_F(HttpNetworkTransactionTest, BuildRequest_PostContentLengthZero) {
TEST_F(HttpNetworkTransactionTest, BuildRequest_PutContentLengthZero) {
scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
- scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
- CreateSession(proxy_service.get()), &mock_socket_factory));
+ scoped_ptr<HttpTransaction> trans(
+ new HttpNetworkTransaction(
+ CreateSession(proxy_service.get(), &mock_socket_factory),
+ &mock_socket_factory));
HttpRequestInfo request;
request.method = "PUT";
@@ -3259,8 +3302,10 @@ TEST_F(HttpNetworkTransactionTest, BuildRequest_PutContentLengthZero) {
TEST_F(HttpNetworkTransactionTest, BuildRequest_HeadContentLengthZero) {
scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
- scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
- CreateSession(proxy_service.get()), &mock_socket_factory));
+ scoped_ptr<HttpTransaction> trans(
+ new HttpNetworkTransaction(
+ CreateSession(proxy_service.get(), &mock_socket_factory),
+ &mock_socket_factory));
HttpRequestInfo request;
request.method = "HEAD";
@@ -3298,8 +3343,10 @@ TEST_F(HttpNetworkTransactionTest, BuildRequest_HeadContentLengthZero) {
TEST_F(HttpNetworkTransactionTest, BuildRequest_CacheControlNoCache) {
scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
- scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
- CreateSession(proxy_service.get()), &mock_socket_factory));
+ scoped_ptr<HttpTransaction> trans(
+ new HttpNetworkTransaction(
+ CreateSession(proxy_service.get(), &mock_socket_factory),
+ &mock_socket_factory));
HttpRequestInfo request;
request.method = "GET";
@@ -3340,8 +3387,10 @@ TEST_F(HttpNetworkTransactionTest, BuildRequest_CacheControlNoCache) {
TEST_F(HttpNetworkTransactionTest,
BuildRequest_CacheControlValidateCache) {
scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
- scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
- CreateSession(proxy_service.get()), &mock_socket_factory));
+ scoped_ptr<HttpTransaction> trans(
+ new HttpNetworkTransaction(
+ CreateSession(proxy_service.get(), &mock_socket_factory),
+ &mock_socket_factory));
HttpRequestInfo request;
request.method = "GET";
@@ -3380,8 +3429,10 @@ TEST_F(HttpNetworkTransactionTest,
TEST_F(HttpNetworkTransactionTest, BuildRequest_ExtraHeaders) {
scoped_ptr<ProxyService> proxy_service(CreateNullProxyService());
- scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
- CreateSession(proxy_service.get()), &mock_socket_factory));
+ scoped_ptr<HttpTransaction> trans(
+ new HttpNetworkTransaction(
+ CreateSession(proxy_service.get(), &mock_socket_factory),
+ &mock_socket_factory));
HttpRequestInfo request;
request.method = "GET";