| 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 // ThreadChecker thread, as we want to kill any pending http traffic without | 217 // ThreadChecker thread, as we want to kill any pending http traffic without |
| 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 // Sets a new auth token and time. |auth_token_time| is an optional parameter | 227 // Sets a new auth token and time. |
| 228 // that contains the date the auth token was fetched/refreshed, and is used | 228 bool SetAuthToken(const std::string& auth_token); |
| 229 // for histogramms/logging only. | |
| 230 bool SetAuthToken(const std::string& auth_token, | |
| 231 const base::Time& auth_token_time); | |
| 232 | 229 |
| 233 // Our out-of-band invalidations channel can encounter auth errors, | 230 // Our out-of-band invalidations channel can encounter auth errors, |
| 234 // and when it does so it tells us via this method to prevent making more | 231 // and when it does so it tells us via this method to prevent making more |
| 235 // requests with known-bad tokens. This will put the | 232 // requests with known-bad tokens. This will put the |
| 236 // ServerConnectionManager in an auth error state as if it received an | 233 // ServerConnectionManager in an auth error state as if it received an |
| 237 // HTTP 401 from sync servers. | 234 // HTTP 401 from sync servers. |
| 238 void OnInvalidationCredentialsRejected(); | 235 void OnInvalidationCredentialsRejected(); |
| 239 | 236 |
| 240 bool HasInvalidAuthToken() { | 237 bool HasInvalidAuthToken() { |
| 241 return auth_token_.empty(); | 238 return auth_token_.empty(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 | 284 |
| 288 // Indicates whether or not requests should be made using HTTPS. | 285 // Indicates whether or not requests should be made using HTTPS. |
| 289 bool use_ssl_; | 286 bool use_ssl_; |
| 290 | 287 |
| 291 // The paths we post to. | 288 // The paths we post to. |
| 292 std::string proto_sync_path_; | 289 std::string proto_sync_path_; |
| 293 | 290 |
| 294 // The auth token to use in authenticated requests. | 291 // The auth token to use in authenticated requests. |
| 295 std::string auth_token_; | 292 std::string auth_token_; |
| 296 | 293 |
| 297 // The time at which this auth token was last created/refreshed. | |
| 298 // Used for histogramming. | |
| 299 base::Time auth_token_time_; | |
| 300 | |
| 301 // The previous auth token that is invalid now. | 294 // The previous auth token that is invalid now. |
| 302 std::string previously_invalidated_token; | 295 std::string previously_invalidated_token; |
| 303 | 296 |
| 304 ObserverList<ServerConnectionEventListener> listeners_; | 297 ObserverList<ServerConnectionEventListener> listeners_; |
| 305 | 298 |
| 306 HttpResponse::ServerConnectionCode server_status_; | 299 HttpResponse::ServerConnectionCode server_status_; |
| 307 | 300 |
| 308 base::ThreadChecker thread_checker_; | 301 base::ThreadChecker thread_checker_; |
| 309 | 302 |
| 310 // Protects all variables below to allow bailing out of active connections. | 303 // Protects all variables below to allow bailing out of active connections. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 void NotifyStatusChanged(); | 335 void NotifyStatusChanged(); |
| 343 | 336 |
| 344 DISALLOW_COPY_AND_ASSIGN(ServerConnectionManager); | 337 DISALLOW_COPY_AND_ASSIGN(ServerConnectionManager); |
| 345 }; | 338 }; |
| 346 | 339 |
| 347 std::ostream& operator<<(std::ostream& s, const struct HttpResponse& hr); | 340 std::ostream& operator<<(std::ostream& s, const struct HttpResponse& hr); |
| 348 | 341 |
| 349 } // namespace syncer | 342 } // namespace syncer |
| 350 | 343 |
| 351 #endif // SYNC_ENGINE_NET_SERVER_CONNECTION_MANAGER_H_ | 344 #endif // SYNC_ENGINE_NET_SERVER_CONNECTION_MANAGER_H_ |
| OLD | NEW |