summaryrefslogtreecommitdiffstats
path: root/google_apis
diff options
context:
space:
mode:
Diffstat (limited to 'google_apis')
-rw-r--r--google_apis/gcm/engine/connection_factory_impl.cc35
-rw-r--r--google_apis/gcm/engine/connection_factory_impl.h19
-rw-r--r--google_apis/gcm/engine/connection_factory_impl_unittest.cc1
-rw-r--r--google_apis/gcm/tools/mcs_probe.cc1
4 files changed, 42 insertions, 14 deletions
diff --git a/google_apis/gcm/engine/connection_factory_impl.cc b/google_apis/gcm/engine/connection_factory_impl.cc
index 0ff3175..f7cd669 100644
--- a/google_apis/gcm/engine/connection_factory_impl.cc
+++ b/google_apis/gcm/engine/connection_factory_impl.cc
@@ -45,14 +45,16 @@ bool ShouldRestorePreviousBackoff(const base::TimeTicks& login_time,
ConnectionFactoryImpl::ConnectionFactoryImpl(
const std::vector<GURL>& mcs_endpoints,
const net::BackoffEntry::Policy& backoff_policy,
- scoped_refptr<net::HttpNetworkSession> network_session,
+ const scoped_refptr<net::HttpNetworkSession>& gcm_network_session,
+ const scoped_refptr<net::HttpNetworkSession>& http_network_session,
net::NetLog* net_log,
GCMStatsRecorder* recorder)
: mcs_endpoints_(mcs_endpoints),
next_endpoint_(0),
last_successful_endpoint_(0),
backoff_policy_(backoff_policy),
- network_session_(network_session),
+ gcm_network_session_(gcm_network_session),
+ http_network_session_(http_network_session),
bound_net_log_(
net::BoundNetLog::Make(net_log, net::NetLog::SOURCE_SOCKET)),
pac_request_(NULL),
@@ -64,13 +66,15 @@ 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()));
}
ConnectionFactoryImpl::~ConnectionFactoryImpl() {
CloseSocket();
net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this);
if (pac_request_) {
- network_session_->proxy_service()->CancelPacRequest(pac_request_);
+ gcm_network_session_->proxy_service()->CancelPacRequest(pac_request_);
pac_request_ = NULL;
}
}
@@ -280,7 +284,8 @@ void ConnectionFactoryImpl::ConnectImpl() {
connecting_ = true;
GURL current_endpoint = GetCurrentEndpoint();
recorder_->RecordConnectionInitiated(current_endpoint.host());
- int status = network_session_->proxy_service()->ResolveProxy(
+ RebuildNetworkSessionAuthCache();
+ int status = gcm_network_session_->proxy_service()->ResolveProxy(
current_endpoint,
net::LOAD_NORMAL,
&proxy_info_,
@@ -425,10 +430,10 @@ void ConnectionFactoryImpl::OnProxyResolveDone(int status) {
DVLOG(1) << "Resolved proxy with PAC:" << proxy_info_.ToPacString();
net::SSLConfig ssl_config;
- network_session_->ssl_config_service()->GetSSLConfig(&ssl_config);
+ gcm_network_session_->ssl_config_service()->GetSSLConfig(&ssl_config);
status = net::InitSocketHandleForTlsConnect(
net::HostPortPair::FromURL(GetCurrentEndpoint()),
- network_session_.get(),
+ gcm_network_session_.get(),
proxy_info_,
ssl_config,
ssl_config,
@@ -494,13 +499,13 @@ int ConnectionFactoryImpl::ReconsiderProxyAfterError(int error) {
}
net::SSLConfig ssl_config;
- network_session_->ssl_config_service()->GetSSLConfig(&ssl_config);
+ gcm_network_session_->ssl_config_service()->GetSSLConfig(&ssl_config);
if (proxy_info_.is_https() && ssl_config.send_client_cert) {
- network_session_->ssl_client_auth_cache()->Remove(
+ gcm_network_session_->ssl_client_auth_cache()->Remove(
proxy_info_.proxy_server().host_port_pair());
}
- int status = network_session_->proxy_service()->ReconsiderProxyAfterError(
+ int status = gcm_network_session_->proxy_service()->ReconsiderProxyAfterError(
GetCurrentEndpoint(), net::LOAD_NORMAL, error, &proxy_info_,
base::Bind(&ConnectionFactoryImpl::OnProxyResolveDone,
weak_ptr_factory_.GetWeakPtr()),
@@ -529,8 +534,8 @@ int ConnectionFactoryImpl::ReconsiderProxyAfterError(int error) {
}
void ConnectionFactoryImpl::ReportSuccessfulProxyConnection() {
- if (network_session_ && network_session_->proxy_service())
- network_session_->proxy_service()->ReportSuccess(proxy_info_);
+ if (gcm_network_session_ && gcm_network_session_->proxy_service())
+ gcm_network_session_->proxy_service()->ReportSuccess(proxy_info_);
}
void ConnectionFactoryImpl::CloseSocket() {
@@ -544,4 +549,12 @@ void ConnectionFactoryImpl::CloseSocket() {
socket_handle_.Reset();
}
+void ConnectionFactoryImpl::RebuildNetworkSessionAuthCache() {
+ if (!http_network_session_ || !http_network_session_->http_auth_cache())
+ return;
+
+ gcm_network_session_->http_auth_cache()->UpdateAllFrom(
+ *http_network_session_->http_auth_cache());
+}
+
} // namespace gcm
diff --git a/google_apis/gcm/engine/connection_factory_impl.h b/google_apis/gcm/engine/connection_factory_impl.h
index 80fbc94..ddd8173 100644
--- a/google_apis/gcm/engine/connection_factory_impl.h
+++ b/google_apis/gcm/engine/connection_factory_impl.h
@@ -31,10 +31,15 @@ class GCM_EXPORT ConnectionFactoryImpl :
public ConnectionFactory,
public net::NetworkChangeNotifier::NetworkChangeObserver {
public:
+ // |http_network_session| is an optional network session to use as a source
+ // 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|.
ConnectionFactoryImpl(
const std::vector<GURL>& mcs_endpoints,
const net::BackoffEntry::Policy& backoff_policy,
- scoped_refptr<net::HttpNetworkSession> network_session,
+ const scoped_refptr<net::HttpNetworkSession>& gcm_network_session,
+ const scoped_refptr<net::HttpNetworkSession>& http_network_session,
net::NetLog* net_log,
GCMStatsRecorder* recorder);
virtual ~ConnectionFactoryImpl();
@@ -110,8 +115,13 @@ class GCM_EXPORT ConnectionFactoryImpl :
int ReconsiderProxyAfterError(int error);
void ReportSuccessfulProxyConnection();
+ // Closes the local socket if one is present, and resets connection handler.
void CloseSocket();
+ // Updates the GCM Network Session's HttpAuthCache with the HTTP Network
+ // Session's cache, if available.
+ void RebuildNetworkSessionAuthCache();
+
// The MCS endpoints to make connections to, sorted in order of priority.
const std::vector<GURL> mcs_endpoints_;
// Index to the endpoint for which a connection should be attempted next.
@@ -123,8 +133,11 @@ class GCM_EXPORT ConnectionFactoryImpl :
const net::BackoffEntry::Policy backoff_policy_;
// ---- net:: components for establishing connections. ----
- // Network session for creating new connections.
- const scoped_refptr<net::HttpNetworkSession> network_session_;
+ // Network session for creating new GCM connections.
+ const scoped_refptr<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_;
// 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/engine/connection_factory_impl_unittest.cc b/google_apis/gcm/engine/connection_factory_impl_unittest.cc
index da9485f..310e831 100644
--- a/google_apis/gcm/engine/connection_factory_impl_unittest.cc
+++ b/google_apis/gcm/engine/connection_factory_impl_unittest.cc
@@ -159,6 +159,7 @@ TestConnectionFactoryImpl::TestConnectionFactoryImpl(
net::BackoffEntry::Policy(),
NULL,
NULL,
+ NULL,
&dummy_recorder_),
connect_result_(net::ERR_UNEXPECTED),
num_expected_attempts_(0),
diff --git a/google_apis/gcm/tools/mcs_probe.cc b/google_apis/gcm/tools/mcs_probe.cc
index 9e090fd..048b48c 100644
--- a/google_apis/gcm/tools/mcs_probe.cc
+++ b/google_apis/gcm/tools/mcs_probe.cc
@@ -303,6 +303,7 @@ void MCSProbe::Start() {
new ConnectionFactoryImpl(endpoints,
kDefaultBackoffPolicy,
network_session_,
+ NULL,
&net_log_,
&recorder_));
gcm_store_.reset(