summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortyoshino@chromium.org <tyoshino@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-07 09:15:20 +0000
committertyoshino@chromium.org <tyoshino@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-07 09:15:20 +0000
commit37b7206a8c304700fb250a4eba8e22dd038a8b04 (patch)
tree770b98a4e323f688d2791d16924beb0dacbb543a
parent0b4e575a9749594defb699b866a236f11d9a5e0f (diff)
downloadchromium_src-37b7206a8c304700fb250a4eba8e22dd038a8b04.zip
chromium_src-37b7206a8c304700fb250a4eba8e22dd038a8b04.tar.gz
chromium_src-37b7206a8c304700fb250a4eba8e22dd038a8b04.tar.bz2
Don't cache URLRequestContext's member in SocketStream.
It's making it hard to understand dependency. Review URL: https://chromiumcodereview.appspot.com/16451007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@204778 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--net/socket_stream/socket_stream.cc23
-rw-r--r--net/socket_stream/socket_stream.h5
2 files changed, 9 insertions, 19 deletions
diff --git a/net/socket_stream/socket_stream.cc b/net/socket_stream/socket_stream.cc
index 2b3b941..6c8cbd3 100644
--- a/net/socket_stream/socket_stream.cc
+++ b/net/socket_stream/socket_stream.cc
@@ -92,9 +92,6 @@ SocketStream::SocketStream(const GURL& url, Delegate* delegate)
max_pending_send_allowed_(kMaxPendingSendAllowed),
context_(NULL),
next_state_(STATE_NONE),
- host_resolver_(NULL),
- cert_verifier_(NULL),
- server_bound_cert_service_(NULL),
factory_(ClientSocketFactory::GetDefaultFactory()),
proxy_mode_(kDirectConnection),
proxy_url_(url),
@@ -155,12 +152,6 @@ void SocketStream::set_context(const URLRequestContext* context) {
net_log_.BeginEvent(NetLog::TYPE_REQUEST_ALIVE);
}
}
-
- if (context_) {
- host_resolver_ = context_->host_resolver();
- cert_verifier_ = context_->cert_verifier();
- server_bound_cert_service_ = context_->server_bound_cert_service();
- }
}
void SocketStream::CheckPrivacyMode() {
@@ -681,8 +672,8 @@ int SocketStream::DoResolveHost() {
HostResolver::RequestInfo resolve_info(host_port_pair);
- DCHECK(host_resolver_);
- resolver_.reset(new SingleRequestHostResolver(host_resolver_));
+ DCHECK(context_->host_resolver());
+ resolver_.reset(new SingleRequestHostResolver(context_->host_resolver()));
return resolver_->Resolve(
resolve_info, &addresses_, base::Bind(&SocketStream::OnIOCompleted, this),
net_log_);
@@ -968,7 +959,7 @@ int SocketStream::DoSOCKSConnect() {
if (proxy_info_.proxy_server().scheme() == ProxyServer::SCHEME_SOCKS5)
s = new SOCKS5ClientSocket(s, req_info);
else
- s = new SOCKSClientSocket(s, req_info, host_resolver_);
+ s = new SOCKSClientSocket(s, req_info, context_->host_resolver());
socket_.reset(s);
metrics_->OnCountConnectionType(SocketStreamMetrics::SOCKS_CONNECTION);
return socket_->Connect(io_callback_);
@@ -991,8 +982,8 @@ int SocketStream::DoSOCKSConnectComplete(int result) {
int SocketStream::DoSecureProxyConnect() {
DCHECK(factory_);
SSLClientSocketContext ssl_context;
- ssl_context.cert_verifier = cert_verifier_;
- ssl_context.server_bound_cert_service = server_bound_cert_service_;
+ ssl_context.cert_verifier = context_->cert_verifier();
+ ssl_context.server_bound_cert_service = context_->server_bound_cert_service();
socket_.reset(factory_->CreateSSLClientSocket(
socket_.release(),
proxy_info_.proxy_server().host_port_pair(),
@@ -1044,8 +1035,8 @@ int SocketStream::DoSecureProxyHandleCertErrorComplete(int result) {
int SocketStream::DoSSLConnect() {
DCHECK(factory_);
SSLClientSocketContext ssl_context;
- ssl_context.cert_verifier = cert_verifier_;
- ssl_context.server_bound_cert_service = server_bound_cert_service_;
+ ssl_context.cert_verifier = context_->cert_verifier();
+ ssl_context.server_bound_cert_service = context_->server_bound_cert_service();
socket_.reset(factory_->CreateSSLClientSocket(socket_.release(),
HostPortPair::FromURL(url_),
server_ssl_config_,
diff --git a/net/socket_stream/socket_stream.h b/net/socket_stream/socket_stream.h
index e4c505b..362d94a 100644
--- a/net/socket_stream/socket_stream.h
+++ b/net/socket_stream/socket_stream.h
@@ -129,6 +129,8 @@ class NET_EXPORT SocketStream
int max_pending_send_allowed() const { return max_pending_send_allowed_; }
const URLRequestContext* context() const { return context_; }
+ // There're some asynchronous operations and members that are constructed from
+ // |context|. Be careful when you use this for the second time or more.
void set_context(const URLRequestContext* context);
const SSLConfig& server_ssl_config() const { return server_ssl_config_; }
@@ -346,9 +348,6 @@ class NET_EXPORT SocketStream
UserDataMap user_data_;
State next_state_;
- HostResolver* host_resolver_;
- CertVerifier* cert_verifier_;
- ServerBoundCertService* server_bound_cert_service_;
ClientSocketFactory* factory_;
ProxyMode proxy_mode_;