OLD | NEW |
---|---|
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 26 matching lines...) Expand all Loading... | |
37 | 37 |
38 // ConnectionFactory implementation. | 38 // ConnectionFactory implementation. |
39 virtual void Initialize( | 39 virtual void Initialize( |
40 const BuildLoginRequestCallback& request_builder, | 40 const BuildLoginRequestCallback& request_builder, |
41 const ConnectionHandler::ProtoReceivedCallback& read_callback, | 41 const ConnectionHandler::ProtoReceivedCallback& read_callback, |
42 const ConnectionHandler::ProtoSentCallback& write_callback) OVERRIDE; | 42 const ConnectionHandler::ProtoSentCallback& write_callback) OVERRIDE; |
43 virtual ConnectionHandler* GetConnectionHandler() const OVERRIDE; | 43 virtual ConnectionHandler* GetConnectionHandler() const OVERRIDE; |
44 virtual void Connect() OVERRIDE; | 44 virtual void Connect() OVERRIDE; |
45 virtual bool IsEndpointReachable() const OVERRIDE; | 45 virtual bool IsEndpointReachable() const OVERRIDE; |
46 virtual base::TimeTicks NextRetryAttempt() const OVERRIDE; | 46 virtual base::TimeTicks NextRetryAttempt() const OVERRIDE; |
47 virtual void SignalConnectionReset() OVERRIDE; | 47 virtual void SignalConnectionReset(ConnectionResetReason reason) OVERRIDE; |
48 | 48 |
49 // NetworkChangeNotifier observer implementations. | 49 // NetworkChangeNotifier observer implementations. |
50 virtual void OnConnectionTypeChanged( | 50 virtual void OnConnectionTypeChanged( |
51 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; | 51 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; |
52 virtual void OnIPAddressChanged() OVERRIDE; | 52 virtual void OnIPAddressChanged() OVERRIDE; |
53 | 53 |
54 protected: | 54 protected: |
55 // Implementation of Connect(..). If not in backoff, uses |login_request_| | 55 // Implementation of Connect(..). If not in backoff, uses |login_request_| |
56 // in attempting a connection/handshake. On connection/handshake failure, goes | 56 // in attempting a connection/handshake. On connection/handshake failure, goes |
57 // into backoff. | 57 // into backoff. |
(...skipping 28 matching lines...) Expand all Loading... | |
86 | 86 |
87 // ---- net:: components for establishing connections. ---- | 87 // ---- net:: components for establishing connections. ---- |
88 // Network session for creating new connections. | 88 // Network session for creating new connections. |
89 const scoped_refptr<net::HttpNetworkSession> network_session_; | 89 const scoped_refptr<net::HttpNetworkSession> network_session_; |
90 // Net log to use in connection attempts. | 90 // Net log to use in connection attempts. |
91 net::NetLog* const net_log_; | 91 net::NetLog* const net_log_; |
92 // The handle to the socket for the current connection, if one exists. | 92 // The handle to the socket for the current connection, if one exists. |
93 net::ClientSocketHandle socket_handle_; | 93 net::ClientSocketHandle socket_handle_; |
94 // Connection attempt backoff policy. | 94 // Connection attempt backoff policy. |
95 scoped_ptr<net::BackoffEntry> backoff_entry_; | 95 scoped_ptr<net::BackoffEntry> backoff_entry_; |
96 // Backoff policy from previous backoff attempt. | 96 // Backoff policy from previous backoff attempt. Updated on each login |
fgorski
2014/02/12 19:24:01
nit: backoff entry
not backoff policy I think.
Nicolas Zea
2014/02/12 21:50:16
Done.
| |
97 // completion. | |
97 scoped_ptr<net::BackoffEntry> previous_backoff_; | 98 scoped_ptr<net::BackoffEntry> previous_backoff_; |
98 base::TimeTicks backoff_reset_time_; | |
99 | 99 |
100 // Whether a connection attempt is currently in progress or we're in backoff | 100 // Whether a connection attempt is currently in progress or we're in backoff |
101 // waiting until the next connection attempt. |!connecting_| denotes | 101 // waiting until the next connection attempt. |!connecting_| denotes |
102 // steady state with an active connection. | 102 // steady state with an active connection. |
103 bool connecting_; | 103 bool connecting_; |
104 | 104 |
105 // Whether login successfully completed after the connection was established. | |
106 // If a connection reset happens while attempting to log in, the current | |
107 // backoff entry is reused (after incrementing with a new failure). | |
108 bool logging_in_; | |
109 | |
110 // The time of the last login completion. Used for calculating whether to | |
111 // restore a previous backoff entry and for measuring uptime. | |
112 base::TimeTicks last_login_time_; | |
113 | |
105 // The current connection handler, if one exists. | 114 // The current connection handler, if one exists. |
106 scoped_ptr<ConnectionHandlerImpl> connection_handler_; | 115 scoped_ptr<ConnectionHandlerImpl> connection_handler_; |
107 | 116 |
108 // Builder for generating new login requests. | 117 // Builder for generating new login requests. |
109 BuildLoginRequestCallback request_builder_; | 118 BuildLoginRequestCallback request_builder_; |
110 | 119 |
111 base::WeakPtrFactory<ConnectionFactoryImpl> weak_ptr_factory_; | 120 base::WeakPtrFactory<ConnectionFactoryImpl> weak_ptr_factory_; |
112 | 121 |
113 DISALLOW_COPY_AND_ASSIGN(ConnectionFactoryImpl); | 122 DISALLOW_COPY_AND_ASSIGN(ConnectionFactoryImpl); |
114 }; | 123 }; |
115 | 124 |
116 } // namespace gcm | 125 } // namespace gcm |
117 | 126 |
118 #endif // GOOGLE_APIS_GCM_ENGINE_CONNECTION_FACTORY_IMPL_H_ | 127 #endif // GOOGLE_APIS_GCM_ENGINE_CONNECTION_FACTORY_IMPL_H_ |
OLD | NEW |