Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(462)

Side by Side Diff: google_apis/gcm/engine/connection_factory_impl.h

Issue 375663002: Leverage profile's http network session's HttpAuthCache to support proxy auth. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef GOOGLE_APIS_GCM_ENGINE_CONNECTION_FACTORY_IMPL_H_ 5 #ifndef GOOGLE_APIS_GCM_ENGINE_CONNECTION_FACTORY_IMPL_H_
6 #define GOOGLE_APIS_GCM_ENGINE_CONNECTION_FACTORY_IMPL_H_ 6 #define GOOGLE_APIS_GCM_ENGINE_CONNECTION_FACTORY_IMPL_H_
7 7
8 #include "google_apis/gcm/engine/connection_factory.h" 8 #include "google_apis/gcm/engine/connection_factory.h"
9 9
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 13 matching lines...) Expand all
24 24
25 namespace gcm { 25 namespace gcm {
26 26
27 class ConnectionHandlerImpl; 27 class ConnectionHandlerImpl;
28 class GCMStatsRecorder; 28 class GCMStatsRecorder;
29 29
30 class GCM_EXPORT ConnectionFactoryImpl : 30 class GCM_EXPORT ConnectionFactoryImpl :
31 public ConnectionFactory, 31 public ConnectionFactory,
32 public net::NetworkChangeNotifier::NetworkChangeObserver { 32 public net::NetworkChangeNotifier::NetworkChangeObserver {
33 public: 33 public:
34 // |http_network_session| is an optional network session to use as a source
35 // for proxy auth credentials (via its HttpAuthCache). |gcm_network_session|
36 // is the network session through which GCM connections should be made, and
37 // must not be the same as |http_network_session|.
34 ConnectionFactoryImpl( 38 ConnectionFactoryImpl(
35 const std::vector<GURL>& mcs_endpoints, 39 const std::vector<GURL>& mcs_endpoints,
36 const net::BackoffEntry::Policy& backoff_policy, 40 const net::BackoffEntry::Policy& backoff_policy,
37 scoped_refptr<net::HttpNetworkSession> network_session, 41 const scoped_refptr<net::HttpNetworkSession>& gcm_network_session,
42 const scoped_refptr<net::HttpNetworkSession>& http_network_session,
38 net::NetLog* net_log, 43 net::NetLog* net_log,
39 GCMStatsRecorder* recorder); 44 GCMStatsRecorder* recorder);
40 virtual ~ConnectionFactoryImpl(); 45 virtual ~ConnectionFactoryImpl();
41 46
42 // ConnectionFactory implementation. 47 // ConnectionFactory implementation.
43 virtual void Initialize( 48 virtual void Initialize(
44 const BuildLoginRequestCallback& request_builder, 49 const BuildLoginRequestCallback& request_builder,
45 const ConnectionHandler::ProtoReceivedCallback& read_callback, 50 const ConnectionHandler::ProtoReceivedCallback& read_callback,
46 const ConnectionHandler::ProtoSentCallback& write_callback) OVERRIDE; 51 const ConnectionHandler::ProtoSentCallback& write_callback) OVERRIDE;
47 virtual ConnectionHandler* GetConnectionHandler() const OVERRIDE; 52 virtual ConnectionHandler* GetConnectionHandler() const OVERRIDE;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 // Helper method for checking backoff and triggering a connection as 108 // Helper method for checking backoff and triggering a connection as
104 // necessary. 109 // necessary.
105 void ConnectWithBackoff(); 110 void ConnectWithBackoff();
106 111
107 // Proxy resolution and connection functions. 112 // Proxy resolution and connection functions.
108 void OnProxyResolveDone(int status); 113 void OnProxyResolveDone(int status);
109 void OnProxyConnectDone(int status); 114 void OnProxyConnectDone(int status);
110 int ReconsiderProxyAfterError(int error); 115 int ReconsiderProxyAfterError(int error);
111 void ReportSuccessfulProxyConnection(); 116 void ReportSuccessfulProxyConnection();
112 117
118 // Closes the local socket if one is present, and resets connection handler.
113 void CloseSocket(); 119 void CloseSocket();
114 120
121 // Updates the GCM Network Session's HttpAuthCache with the HTTP Network
122 // Session's cache, if available.
123 void RebuildNetworkSessionAuthCache();
124
115 // The MCS endpoints to make connections to, sorted in order of priority. 125 // The MCS endpoints to make connections to, sorted in order of priority.
116 const std::vector<GURL> mcs_endpoints_; 126 const std::vector<GURL> mcs_endpoints_;
117 // Index to the endpoint for which a connection should be attempted next. 127 // Index to the endpoint for which a connection should be attempted next.
118 size_t next_endpoint_; 128 size_t next_endpoint_;
119 // Index to the endpoint that was last successfully connected. 129 // Index to the endpoint that was last successfully connected.
120 size_t last_successful_endpoint_; 130 size_t last_successful_endpoint_;
121 131
122 // The backoff policy to use. 132 // The backoff policy to use.
123 const net::BackoffEntry::Policy backoff_policy_; 133 const net::BackoffEntry::Policy backoff_policy_;
124 134
125 // ---- net:: components for establishing connections. ---- 135 // ---- net:: components for establishing connections. ----
126 // Network session for creating new connections. 136 // Network session for creating new GCM connections.
127 const scoped_refptr<net::HttpNetworkSession> network_session_; 137 const scoped_refptr<net::HttpNetworkSession> gcm_network_session_;
138 // HTTP Network session. If set, is used for extracting proxy auth
139 // credentials. If not set, is ignored.
140 const scoped_refptr<net::HttpNetworkSession> http_network_session_;
128 // Net log to use in connection attempts. 141 // Net log to use in connection attempts.
129 net::BoundNetLog bound_net_log_; 142 net::BoundNetLog bound_net_log_;
130 // The current PAC request, if one exists. Owned by the proxy service. 143 // The current PAC request, if one exists. Owned by the proxy service.
131 net::ProxyService::PacRequest* pac_request_; 144 net::ProxyService::PacRequest* pac_request_;
132 // The current proxy info. 145 // The current proxy info.
133 net::ProxyInfo proxy_info_; 146 net::ProxyInfo proxy_info_;
134 // The handle to the socket for the current connection, if one exists. 147 // The handle to the socket for the current connection, if one exists.
135 net::ClientSocketHandle socket_handle_; 148 net::ClientSocketHandle socket_handle_;
136 // Current backoff entry. 149 // Current backoff entry.
137 scoped_ptr<net::BackoffEntry> backoff_entry_; 150 scoped_ptr<net::BackoffEntry> backoff_entry_;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 ConnectionListener* listener_; 187 ConnectionListener* listener_;
175 188
176 base::WeakPtrFactory<ConnectionFactoryImpl> weak_ptr_factory_; 189 base::WeakPtrFactory<ConnectionFactoryImpl> weak_ptr_factory_;
177 190
178 DISALLOW_COPY_AND_ASSIGN(ConnectionFactoryImpl); 191 DISALLOW_COPY_AND_ASSIGN(ConnectionFactoryImpl);
179 }; 192 };
180 193
181 } // namespace gcm 194 } // namespace gcm
182 195
183 #endif // GOOGLE_APIS_GCM_ENGINE_CONNECTION_FACTORY_IMPL_H_ 196 #endif // GOOGLE_APIS_GCM_ENGINE_CONNECTION_FACTORY_IMPL_H_
OLDNEW
« no previous file with comments | « components/gcm_driver/gcm_client_impl_unittest.cc ('k') | google_apis/gcm/engine/connection_factory_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698