summaryrefslogtreecommitdiffstats
path: root/google_apis
diff options
context:
space:
mode:
authormmenke <mmenke@chromium.org>2015-10-13 10:16:42 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-13 17:17:29 +0000
commite65e7af826f0a081c6e9704381e9604afe26ca09 (patch)
tree8dd89f82fb3e174f293ec43c22ad8a908196b034 /google_apis
parent5187806982cdaf12248d947a3f12c544a1ae79b3 (diff)
downloadchromium_src-e65e7af826f0a081c6e9704381e9604afe26ca09.zip
chromium_src-e65e7af826f0a081c6e9704381e9604afe26ca09.tar.gz
chromium_src-e65e7af826f0a081c6e9704381e9604afe26ca09.tar.bz2
Reland remove reference counting from HttpNetworkSession.
This was originally landed in https://crrev.com/468be2ff331c13b1a081d10a3c17e5366d26e577 and reverted in https://crrev.com/6b3af6e07d19ebb3f86df612ee5a08c8dc8f78ab, due to a new leak in a test causing bots to crash in a fun and exciting manner. BUG=515947 TBR=sgurun@chromium.org,davidben@chromium.org,droger@chromium.org,zea@chromium.org Review URL: https://codereview.chromium.org/1389743003 Cr-Commit-Position: refs/heads/master@{#353774}
Diffstat (limited to 'google_apis')
-rw-r--r--google_apis/gcm/engine/connection_factory_impl.cc15
-rw-r--r--google_apis/gcm/engine/connection_factory_impl.h13
-rw-r--r--google_apis/gcm/tools/mcs_probe.cc6
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 1063db9..b2acc19 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() {