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 <stddef.h> | 10 #include <stddef.h> |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 // into backoff. | 83 // into backoff. |
84 // Virtual for testing. | 84 // Virtual for testing. |
85 virtual void ConnectImpl(); | 85 virtual void ConnectImpl(); |
86 | 86 |
87 // Helper method for initalizing the connection hander. | 87 // Helper method for initalizing the connection hander. |
88 // Virtual for testing. | 88 // Virtual for testing. |
89 virtual void InitHandler(); | 89 virtual void InitHandler(); |
90 | 90 |
91 // Helper method for creating a backoff entry. | 91 // Helper method for creating a backoff entry. |
92 // Virtual for testing. | 92 // Virtual for testing. |
93 virtual scoped_ptr<net::BackoffEntry> CreateBackoffEntry( | 93 virtual std::unique_ptr<net::BackoffEntry> CreateBackoffEntry( |
94 const net::BackoffEntry::Policy* const policy); | 94 const net::BackoffEntry::Policy* const policy); |
95 | 95 |
96 // Helper method for creating the connection handler. | 96 // Helper method for creating the connection handler. |
97 // Virtual for testing. | 97 // Virtual for testing. |
98 virtual scoped_ptr<ConnectionHandler> CreateConnectionHandler( | 98 virtual std::unique_ptr<ConnectionHandler> CreateConnectionHandler( |
99 base::TimeDelta read_timeout, | 99 base::TimeDelta read_timeout, |
100 const ConnectionHandler::ProtoReceivedCallback& read_callback, | 100 const ConnectionHandler::ProtoReceivedCallback& read_callback, |
101 const ConnectionHandler::ProtoSentCallback& write_callback, | 101 const ConnectionHandler::ProtoSentCallback& write_callback, |
102 const ConnectionHandler::ConnectionChangedCallback& connection_callback); | 102 const ConnectionHandler::ConnectionChangedCallback& connection_callback); |
103 | 103 |
104 // Returns the current time in Ticks. | 104 // Returns the current time in Ticks. |
105 // Virtual for testing. | 105 // Virtual for testing. |
106 virtual base::TimeTicks NowTicks(); | 106 virtual base::TimeTicks NowTicks(); |
107 | 107 |
108 // Callback for Socket connection completion. | 108 // Callback for Socket connection completion. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 net::HttpNetworkSession* http_network_session_; | 147 net::HttpNetworkSession* http_network_session_; |
148 // Net log to use in connection attempts. | 148 // Net log to use in connection attempts. |
149 net::BoundNetLog bound_net_log_; | 149 net::BoundNetLog bound_net_log_; |
150 // The current PAC request, if one exists. Owned by the proxy service. | 150 // The current PAC request, if one exists. Owned by the proxy service. |
151 net::ProxyService::PacRequest* pac_request_; | 151 net::ProxyService::PacRequest* pac_request_; |
152 // The current proxy info. | 152 // The current proxy info. |
153 net::ProxyInfo proxy_info_; | 153 net::ProxyInfo proxy_info_; |
154 // The handle to the socket for the current connection, if one exists. | 154 // The handle to the socket for the current connection, if one exists. |
155 net::ClientSocketHandle socket_handle_; | 155 net::ClientSocketHandle socket_handle_; |
156 // Current backoff entry. | 156 // Current backoff entry. |
157 scoped_ptr<net::BackoffEntry> backoff_entry_; | 157 std::unique_ptr<net::BackoffEntry> backoff_entry_; |
158 // Backoff entry from previous connection attempt. Updated on each login | 158 // Backoff entry from previous connection attempt. Updated on each login |
159 // completion. | 159 // completion. |
160 scoped_ptr<net::BackoffEntry> previous_backoff_; | 160 std::unique_ptr<net::BackoffEntry> previous_backoff_; |
161 | 161 |
162 // Whether a connection attempt is currently actively in progress. | 162 // Whether a connection attempt is currently actively in progress. |
163 bool connecting_; | 163 bool connecting_; |
164 | 164 |
165 // Whether the client is waiting for backoff to finish before attempting to | 165 // Whether the client is waiting for backoff to finish before attempting to |
166 // connect. Canary jobs are able to preempt connections pending backoff | 166 // connect. Canary jobs are able to preempt connections pending backoff |
167 // expiration. | 167 // expiration. |
168 bool waiting_for_backoff_; | 168 bool waiting_for_backoff_; |
169 | 169 |
170 // Whether the NetworkChangeNotifier has informed the client that there is | 170 // Whether the NetworkChangeNotifier has informed the client that there is |
171 // no current connection. No connection attempts will be made until the | 171 // no current connection. No connection attempts will be made until the |
172 // client is informed of a valid connection type. | 172 // client is informed of a valid connection type. |
173 bool waiting_for_network_online_; | 173 bool waiting_for_network_online_; |
174 | 174 |
175 // Whether login successfully completed after the connection was established. | 175 // Whether login successfully completed after the connection was established. |
176 // If a connection reset happens while attempting to log in, the current | 176 // If a connection reset happens while attempting to log in, the current |
177 // backoff entry is reused (after incrementing with a new failure). | 177 // backoff entry is reused (after incrementing with a new failure). |
178 bool logging_in_; | 178 bool logging_in_; |
179 | 179 |
180 // The time of the last login completion. Used for calculating whether to | 180 // The time of the last login completion. Used for calculating whether to |
181 // restore a previous backoff entry and for measuring uptime. | 181 // restore a previous backoff entry and for measuring uptime. |
182 base::TimeTicks last_login_time_; | 182 base::TimeTicks last_login_time_; |
183 | 183 |
184 // Cached callbacks. Set at |Initialize| time, consumed at first |Connect| | 184 // Cached callbacks. Set at |Initialize| time, consumed at first |Connect| |
185 // time. | 185 // time. |
186 ConnectionHandler::ProtoReceivedCallback read_callback_; | 186 ConnectionHandler::ProtoReceivedCallback read_callback_; |
187 ConnectionHandler::ProtoSentCallback write_callback_; | 187 ConnectionHandler::ProtoSentCallback write_callback_; |
188 | 188 |
189 // The current connection handler, if one exists. | 189 // The current connection handler, if one exists. |
190 scoped_ptr<ConnectionHandler> connection_handler_; | 190 std::unique_ptr<ConnectionHandler> connection_handler_; |
191 | 191 |
192 // Builder for generating new login requests. | 192 // Builder for generating new login requests. |
193 BuildLoginRequestCallback request_builder_; | 193 BuildLoginRequestCallback request_builder_; |
194 | 194 |
195 // Recorder that records GCM activities for debugging purpose. Not owned. | 195 // Recorder that records GCM activities for debugging purpose. Not owned. |
196 GCMStatsRecorder* recorder_; | 196 GCMStatsRecorder* recorder_; |
197 | 197 |
198 // Listener for connection change events. | 198 // Listener for connection change events. |
199 ConnectionListener* listener_; | 199 ConnectionListener* listener_; |
200 | 200 |
201 base::WeakPtrFactory<ConnectionFactoryImpl> weak_ptr_factory_; | 201 base::WeakPtrFactory<ConnectionFactoryImpl> weak_ptr_factory_; |
202 | 202 |
203 DISALLOW_COPY_AND_ASSIGN(ConnectionFactoryImpl); | 203 DISALLOW_COPY_AND_ASSIGN(ConnectionFactoryImpl); |
204 }; | 204 }; |
205 | 205 |
206 } // namespace gcm | 206 } // namespace gcm |
207 | 207 |
208 #endif // GOOGLE_APIS_GCM_ENGINE_CONNECTION_FACTORY_IMPL_H_ | 208 #endif // GOOGLE_APIS_GCM_ENGINE_CONNECTION_FACTORY_IMPL_H_ |
OLD | NEW |