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

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

Issue 206873006: [GCM] Add port 443 fallback logic and histograms (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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
« no previous file with comments | « no previous file | google_apis/gcm/engine/connection_factory_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 14 matching lines...) Expand all
25 namespace gcm { 25 namespace gcm {
26 26
27 class ConnectionHandlerImpl; 27 class ConnectionHandlerImpl;
28 28
29 class GCM_EXPORT ConnectionFactoryImpl : 29 class GCM_EXPORT ConnectionFactoryImpl :
30 public ConnectionFactory, 30 public ConnectionFactory,
31 public net::NetworkChangeNotifier::ConnectionTypeObserver, 31 public net::NetworkChangeNotifier::ConnectionTypeObserver,
32 public net::NetworkChangeNotifier::IPAddressObserver { 32 public net::NetworkChangeNotifier::IPAddressObserver {
33 public: 33 public:
34 ConnectionFactoryImpl( 34 ConnectionFactoryImpl(
35 const GURL& mcs_endpoint, 35 const std::vector<GURL>& mcs_endpoints,
36 const net::BackoffEntry::Policy& backoff_policy, 36 const net::BackoffEntry::Policy& backoff_policy,
37 scoped_refptr<net::HttpNetworkSession> network_session, 37 scoped_refptr<net::HttpNetworkSession> network_session,
38 net::NetLog* net_log); 38 net::NetLog* net_log);
39 virtual ~ConnectionFactoryImpl(); 39 virtual ~ConnectionFactoryImpl();
40 40
41 // ConnectionFactory implementation. 41 // ConnectionFactory implementation.
42 virtual void Initialize( 42 virtual void Initialize(
43 const BuildLoginRequestCallback& request_builder, 43 const BuildLoginRequestCallback& request_builder,
44 const ConnectionHandler::ProtoReceivedCallback& read_callback, 44 const ConnectionHandler::ProtoReceivedCallback& read_callback,
45 const ConnectionHandler::ProtoSentCallback& write_callback) OVERRIDE; 45 const ConnectionHandler::ProtoSentCallback& write_callback) OVERRIDE;
46 virtual ConnectionHandler* GetConnectionHandler() const OVERRIDE; 46 virtual ConnectionHandler* GetConnectionHandler() const OVERRIDE;
47 virtual void Connect() OVERRIDE; 47 virtual void Connect() OVERRIDE;
48 virtual bool IsEndpointReachable() const OVERRIDE; 48 virtual bool IsEndpointReachable() const OVERRIDE;
49 virtual base::TimeTicks NextRetryAttempt() const OVERRIDE; 49 virtual base::TimeTicks NextRetryAttempt() const OVERRIDE;
50 virtual void SignalConnectionReset(ConnectionResetReason reason) OVERRIDE; 50 virtual void SignalConnectionReset(ConnectionResetReason reason) OVERRIDE;
51 51
52 // NetworkChangeNotifier observer implementations. 52 // NetworkChangeNotifier observer implementations.
53 virtual void OnConnectionTypeChanged( 53 virtual void OnConnectionTypeChanged(
54 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; 54 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE;
55 virtual void OnIPAddressChanged() OVERRIDE; 55 virtual void OnIPAddressChanged() OVERRIDE;
56 56
57 // Returns the server to which the factory is currently connected, or if
58 // a connection is currently pending, the server to which the next connection
59 // attempt will be made.
60 GURL GetCurrentEndpoint() const;
61
57 protected: 62 protected:
58 // Implementation of Connect(..). If not in backoff, uses |login_request_| 63 // Implementation of Connect(..). If not in backoff, uses |login_request_|
59 // in attempting a connection/handshake. On connection/handshake failure, goes 64 // in attempting a connection/handshake. On connection/handshake failure, goes
60 // into backoff. 65 // into backoff.
61 // Virtual for testing. 66 // Virtual for testing.
62 virtual void ConnectImpl(); 67 virtual void ConnectImpl();
63 68
64 // Helper method for initalizing the connection hander. 69 // Helper method for initalizing the connection hander.
65 // Virtual for testing. 70 // Virtual for testing.
66 virtual void InitHandler(); 71 virtual void InitHandler();
(...skipping 15 matching lines...) Expand all
82 87
83 private: 88 private:
84 // Proxy resolution and connection functions. 89 // Proxy resolution and connection functions.
85 void OnProxyResolveDone(int status); 90 void OnProxyResolveDone(int status);
86 void OnProxyConnectDone(int status); 91 void OnProxyConnectDone(int status);
87 int ReconsiderProxyAfterError(int error); 92 int ReconsiderProxyAfterError(int error);
88 void ReportSuccessfulProxyConnection(); 93 void ReportSuccessfulProxyConnection();
89 94
90 void CloseSocket(); 95 void CloseSocket();
91 96
92 // The MCS endpoint to make connections to. 97 // The MCS endpoints to make connections to, sorted in order of priority.
93 const GURL mcs_endpoint_; 98 const std::vector<GURL> mcs_endpoints_;
99 // Index to the endpoint for which a connection should be attempted next.
100 size_t next_endpoint_;
101 // Index to the endpoint that was last successfully connected.
102 size_t last_successful_endpoint_;
94 103
95 // The backoff policy to use. 104 // The backoff policy to use.
96 const net::BackoffEntry::Policy backoff_policy_; 105 const net::BackoffEntry::Policy backoff_policy_;
97 106
98 // ---- net:: components for establishing connections. ---- 107 // ---- net:: components for establishing connections. ----
99 // Network session for creating new connections. 108 // Network session for creating new connections.
100 const scoped_refptr<net::HttpNetworkSession> network_session_; 109 const scoped_refptr<net::HttpNetworkSession> network_session_;
101 // Net log to use in connection attempts. 110 // Net log to use in connection attempts.
102 net::BoundNetLog bound_net_log_; 111 net::BoundNetLog bound_net_log_;
103 // The current PAC request, if one exists. Owned by the proxy service. 112 // The current PAC request, if one exists. Owned by the proxy service.
(...skipping 29 matching lines...) Expand all
133 BuildLoginRequestCallback request_builder_; 142 BuildLoginRequestCallback request_builder_;
134 143
135 base::WeakPtrFactory<ConnectionFactoryImpl> weak_ptr_factory_; 144 base::WeakPtrFactory<ConnectionFactoryImpl> weak_ptr_factory_;
136 145
137 DISALLOW_COPY_AND_ASSIGN(ConnectionFactoryImpl); 146 DISALLOW_COPY_AND_ASSIGN(ConnectionFactoryImpl);
138 }; 147 };
139 148
140 } // namespace gcm 149 } // namespace gcm
141 150
142 #endif // GOOGLE_APIS_GCM_ENGINE_CONNECTION_FACTORY_IMPL_H_ 151 #endif // GOOGLE_APIS_GCM_ENGINE_CONNECTION_FACTORY_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | google_apis/gcm/engine/connection_factory_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698