OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 SYNC_ENGINE_NET_SERVER_CONNECTION_MANAGER_H_ | 5 #ifndef SYNC_ENGINE_NET_SERVER_CONNECTION_MANAGER_H_ |
6 #define SYNC_ENGINE_NET_SERVER_CONNECTION_MANAGER_H_ | 6 #define SYNC_ENGINE_NET_SERVER_CONNECTION_MANAGER_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
218 // having to wait for the request to complete. | 218 // having to wait for the request to complete. |
219 void TerminateAllIO(); | 219 void TerminateAllIO(); |
220 | 220 |
221 void set_client_id(const std::string& client_id) { | 221 void set_client_id(const std::string& client_id) { |
222 DCHECK(thread_checker_.CalledOnValidThread()); | 222 DCHECK(thread_checker_.CalledOnValidThread()); |
223 DCHECK(client_id_.empty()); | 223 DCHECK(client_id_.empty()); |
224 client_id_.assign(client_id); | 224 client_id_.assign(client_id); |
225 } | 225 } |
226 | 226 |
227 // Returns true if the auth token is succesfully set and false otherwise. | 227 // Returns true if the auth token is succesfully set and false otherwise. |
228 bool set_auth_token(const std::string& auth_token) { | 228 bool set_auth_token(const std::string& auth_token, |
tim (not reviewing)
2013/05/03 00:46:43
This method should be renamed as per style guide (
Nicolas Zea
2013/05/03 01:31:41
Done.
| |
229 const base::Time& auth_token_time) { | |
229 DCHECK(thread_checker_.CalledOnValidThread()); | 230 DCHECK(thread_checker_.CalledOnValidThread()); |
230 if (previously_invalidated_token != auth_token) { | 231 if (previously_invalidated_token != auth_token) { |
231 auth_token_.assign(auth_token); | 232 auth_token_.assign(auth_token); |
233 auth_token_time_ = auth_token_time; | |
232 previously_invalidated_token = std::string(); | 234 previously_invalidated_token = std::string(); |
233 return true; | 235 return true; |
234 } | 236 } |
235 return false; | 237 return false; |
236 } | 238 } |
237 | 239 |
238 // Our out-of-band invalidations channel can encounter auth errors, | 240 // Our out-of-band invalidations channel can encounter auth errors, |
239 // and when it does so it tells us via this method to prevent making more | 241 // and when it does so it tells us via this method to prevent making more |
240 // requests with known-bad tokens. This will put the | 242 // requests with known-bad tokens. This will put the |
241 // ServerConnectionManager in an auth error state as if it received an | 243 // ServerConnectionManager in an auth error state as if it received an |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
292 | 294 |
293 // Indicates whether or not requests should be made using HTTPS. | 295 // Indicates whether or not requests should be made using HTTPS. |
294 bool use_ssl_; | 296 bool use_ssl_; |
295 | 297 |
296 // The paths we post to. | 298 // The paths we post to. |
297 std::string proto_sync_path_; | 299 std::string proto_sync_path_; |
298 | 300 |
299 // The auth token to use in authenticated requests. | 301 // The auth token to use in authenticated requests. |
300 std::string auth_token_; | 302 std::string auth_token_; |
301 | 303 |
304 // The time at which this auth token was last created/refreshed. | |
305 // Used for histogramming. | |
306 base::Time auth_token_time_; | |
307 | |
302 // The previous auth token that is invalid now. | 308 // The previous auth token that is invalid now. |
303 std::string previously_invalidated_token; | 309 std::string previously_invalidated_token; |
304 | 310 |
305 ObserverList<ServerConnectionEventListener> listeners_; | 311 ObserverList<ServerConnectionEventListener> listeners_; |
306 | 312 |
307 HttpResponse::ServerConnectionCode server_status_; | 313 HttpResponse::ServerConnectionCode server_status_; |
308 | 314 |
309 base::ThreadChecker thread_checker_; | 315 base::ThreadChecker thread_checker_; |
310 | 316 |
311 // Protects all variables below to allow bailing out of active connections. | 317 // Protects all variables below to allow bailing out of active connections. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
343 void NotifyStatusChanged(); | 349 void NotifyStatusChanged(); |
344 | 350 |
345 DISALLOW_COPY_AND_ASSIGN(ServerConnectionManager); | 351 DISALLOW_COPY_AND_ASSIGN(ServerConnectionManager); |
346 }; | 352 }; |
347 | 353 |
348 std::ostream& operator<<(std::ostream& s, const struct HttpResponse& hr); | 354 std::ostream& operator<<(std::ostream& s, const struct HttpResponse& hr); |
349 | 355 |
350 } // namespace syncer | 356 } // namespace syncer |
351 | 357 |
352 #endif // SYNC_ENGINE_NET_SERVER_CONNECTION_MANAGER_H_ | 358 #endif // SYNC_ENGINE_NET_SERVER_CONNECTION_MANAGER_H_ |
OLD | NEW |