diff options
author | mmenke <mmenke@chromium.org> | 2015-09-11 13:42:27 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-09-11 20:43:11 +0000 |
commit | 468be2ff331c13b1a081d10a3c17e5366d26e577 (patch) | |
tree | cee2dbcb52ab7a5af00b531b8e614255a88c7ba6 /google_apis | |
parent | 7c54a1d92f5d20997f58cdc70bd5b51a4a77efee (diff) | |
download | chromium_src-468be2ff331c13b1a081d10a3c17e5366d26e577.zip chromium_src-468be2ff331c13b1a081d10a3c17e5366d26e577.tar.gz chromium_src-468be2ff331c13b1a081d10a3c17e5366d26e577.tar.bz2 |
Remove reference counting from HttpNetworkSession.
This makes lifetime cleaner, and helps us avoid the case
where an HttpNetworkSession outlives the components it points
to.
Also remove some weird uses a null NetLog in GCM.
TBR=sgurun@chromium.org,davidben@chromium.org,droger@chromium.org
BUG=515947
Review URL: https://codereview.chromium.org/1298253002
Cr-Commit-Position: refs/heads/master@{#348483}
Diffstat (limited to 'google_apis')
-rw-r--r-- | google_apis/gcm/engine/connection_factory_impl.cc | 15 | ||||
-rw-r--r-- | google_apis/gcm/engine/connection_factory_impl.h | 13 | ||||
-rw-r--r-- | google_apis/gcm/tools/mcs_probe.cc | 6 |
3 files changed, 19 insertions, 15 deletions
diff --git a/google_apis/gcm/engine/connection_factory_impl.cc b/google_apis/gcm/engine/connection_factory_impl.cc index 4c4f279..19f456c 100644 --- a/google_apis/gcm/engine/connection_factory_impl.cc +++ b/google_apis/gcm/engine/connection_factory_impl.cc @@ -16,6 +16,7 @@ #include "net/base/net_errors.h" #include "net/http/http_network_session.h" #include "net/http/http_request_headers.h" +#include "net/log/net_log.h" #include "net/proxy/proxy_info.h" #include "net/socket/client_socket_handle.h" #include "net/socket/client_socket_pool_manager.h" @@ -47,8 +48,8 @@ bool ShouldRestorePreviousBackoff(const base::TimeTicks& login_time, ConnectionFactoryImpl::ConnectionFactoryImpl( const std::vector<GURL>& mcs_endpoints, const net::BackoffEntry::Policy& backoff_policy, - const scoped_refptr<net::HttpNetworkSession>& gcm_network_session, - const scoped_refptr<net::HttpNetworkSession>& http_network_session, + net::HttpNetworkSession* gcm_network_session, + net::HttpNetworkSession* http_network_session, net::NetLog* net_log, GCMStatsRecorder* recorder) : mcs_endpoints_(mcs_endpoints), @@ -68,8 +69,8 @@ ConnectionFactoryImpl::ConnectionFactoryImpl( listener_(NULL), weak_ptr_factory_(this) { DCHECK_GE(mcs_endpoints_.size(), 1U); - DCHECK(!http_network_session_.get() || - (gcm_network_session_.get() != http_network_session_.get())); + DCHECK(!http_network_session_ || + (gcm_network_session_ != http_network_session_)); } ConnectionFactoryImpl::~ConnectionFactoryImpl() { @@ -457,7 +458,7 @@ void ConnectionFactoryImpl::OnProxyResolveDone(int status) { gcm_network_session_->ssl_config_service()->GetSSLConfig(&ssl_config); status = net::InitSocketHandleForTlsConnect( net::HostPortPair::FromURL(GetCurrentEndpoint()), - gcm_network_session_.get(), + gcm_network_session_, proxy_info_, ssl_config, ssl_config, @@ -558,7 +559,7 @@ int ConnectionFactoryImpl::ReconsiderProxyAfterError(int error) { } void ConnectionFactoryImpl::ReportSuccessfulProxyConnection() { - if (gcm_network_session_.get() && gcm_network_session_->proxy_service()) + if (gcm_network_session_ && gcm_network_session_->proxy_service()) gcm_network_session_->proxy_service()->ReportSuccess(proxy_info_, NULL); } @@ -574,7 +575,7 @@ void ConnectionFactoryImpl::CloseSocket() { } void ConnectionFactoryImpl::RebuildNetworkSessionAuthCache() { - if (!http_network_session_.get() || !http_network_session_->http_auth_cache()) + if (!http_network_session_ || !http_network_session_->http_auth_cache()) return; gcm_network_session_->http_auth_cache()->UpdateAllFrom( diff --git a/google_apis/gcm/engine/connection_factory_impl.h b/google_apis/gcm/engine/connection_factory_impl.h index d979208..a07de12 100644 --- a/google_apis/gcm/engine/connection_factory_impl.h +++ b/google_apis/gcm/engine/connection_factory_impl.h @@ -36,11 +36,14 @@ class GCM_EXPORT ConnectionFactoryImpl : // for proxy auth credentials (via its HttpAuthCache). |gcm_network_session| // is the network session through which GCM connections should be made, and // must not be the same as |http_network_session|. + // + // The caller is responsible for making sure the ConnectionFactoryImpl is + // destroyed before the |gcm_network_session| and |http_network_session|. ConnectionFactoryImpl( const std::vector<GURL>& mcs_endpoints, const net::BackoffEntry::Policy& backoff_policy, - const scoped_refptr<net::HttpNetworkSession>& gcm_network_session, - const scoped_refptr<net::HttpNetworkSession>& http_network_session, + net::HttpNetworkSession* gcm_network_session, + net::HttpNetworkSession* http_network_session, net::NetLog* net_log, GCMStatsRecorder* recorder); ~ConnectionFactoryImpl() override; @@ -135,10 +138,10 @@ class GCM_EXPORT ConnectionFactoryImpl : // ---- net:: components for establishing connections. ---- // Network session for creating new GCM connections. - const scoped_refptr<net::HttpNetworkSession> gcm_network_session_; + net::HttpNetworkSession* gcm_network_session_; // HTTP Network session. If set, is used for extracting proxy auth - // credentials. If not set, is ignored. - const scoped_refptr<net::HttpNetworkSession> http_network_session_; + // credentials. If nullptr, is ignored. + net::HttpNetworkSession* http_network_session_; // Net log to use in connection attempts. net::BoundNetLog bound_net_log_; // The current PAC request, if one exists. Owned by the proxy service. diff --git a/google_apis/gcm/tools/mcs_probe.cc b/google_apis/gcm/tools/mcs_probe.cc index 9d0881b..1ee66d9 100644 --- a/google_apis/gcm/tools/mcs_probe.cc +++ b/google_apis/gcm/tools/mcs_probe.cc @@ -229,7 +229,7 @@ class MCSProbe { scoped_ptr<net::HttpAuthHandlerFactory> http_auth_handler_factory_; scoped_ptr<net::HttpServerPropertiesImpl> http_server_properties_; scoped_ptr<net::HostMappingRules> host_mapping_rules_; - scoped_refptr<net::HttpNetworkSession> network_session_; + scoped_ptr<net::HttpNetworkSession> network_session_; scoped_ptr<net::ProxyService> proxy_service_; FakeGCMStatsRecorder recorder_; @@ -293,7 +293,7 @@ void MCSProbe::Start() { connection_factory_.reset( new ConnectionFactoryImpl(endpoints, kDefaultBackoffPolicy, - network_session_, + network_session_.get(), NULL, &net_log_, &recorder_)); @@ -403,7 +403,7 @@ void MCSProbe::BuildNetworkSession() { session_params.net_log = &net_log_; session_params.proxy_service = proxy_service_.get(); - network_session_ = new net::HttpNetworkSession(session_params); + network_session_.reset(new net::HttpNetworkSession(session_params)); } void MCSProbe::ErrorCallback() { |