| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_BROWSER_SYNC_ENGINE_NET_SERVER_CONNECTION_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_ENGINE_NET_SERVER_CONNECTION_MANAGER_H_ |
| 6 #define CHROME_BROWSER_SYNC_ENGINE_NET_SERVER_CONNECTION_MANAGER_H_ | 6 #define CHROME_BROWSER_SYNC_ENGINE_NET_SERVER_CONNECTION_MANAGER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <iosfwd> | 9 #include <iosfwd> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 int ReadResponse(void* buffer, int length); | 206 int ReadResponse(void* buffer, int length); |
| 207 int ReadResponse(std::string* buffer, int length); | 207 int ReadResponse(std::string* buffer, int length); |
| 208 RequestTimingInfo* timing_info_; | 208 RequestTimingInfo* timing_info_; |
| 209 }; | 209 }; |
| 210 | 210 |
| 211 // The lifetime of the GaiaAuthenticator must be longer than the instance | 211 // The lifetime of the GaiaAuthenticator must be longer than the instance |
| 212 // of the ServerConnectionManager that you're creating. | 212 // of the ServerConnectionManager that you're creating. |
| 213 ServerConnectionManager(const std::string& server, | 213 ServerConnectionManager(const std::string& server, |
| 214 int port, | 214 int port, |
| 215 bool use_ssl, | 215 bool use_ssl, |
| 216 const std::string& user_agent, | 216 const std::string& user_agent); |
| 217 const std::string& client_id); | |
| 218 | 217 |
| 219 virtual ~ServerConnectionManager(); | 218 virtual ~ServerConnectionManager(); |
| 220 | 219 |
| 221 // POSTS buffer_in and reads a response into buffer_out. Uses our currently | 220 // POSTS buffer_in and reads a response into buffer_out. Uses our currently |
| 222 // set auth token in our headers. | 221 // set auth token in our headers. |
| 223 // | 222 // |
| 224 // Returns true if executed successfully. | 223 // Returns true if executed successfully. |
| 225 virtual bool PostBufferWithCachedAuth(const PostBufferParams* params, | 224 virtual bool PostBufferWithCachedAuth(const PostBufferParams* params, |
| 226 ScopedServerStatusWatcher* watcher); | 225 ScopedServerStatusWatcher* watcher); |
| 227 | 226 |
| 228 // POSTS buffer_in and reads a response into buffer_out. Add a specific auth | |
| 229 // token to http headers. | |
| 230 // | |
| 231 // Returns true if executed successfully. | |
| 232 virtual bool PostBufferWithAuth(const PostBufferParams* params, | |
| 233 const std::string& auth_token, | |
| 234 ScopedServerStatusWatcher* watcher); | |
| 235 | |
| 236 // Checks the time on the server. Returns false if the request failed. |time| | 227 // Checks the time on the server. Returns false if the request failed. |time| |
| 237 // is an out parameter that stores the value returned from the server. | 228 // is an out parameter that stores the value returned from the server. |
| 238 virtual bool CheckTime(int32* out_time); | 229 virtual bool CheckTime(int32* out_time); |
| 239 | 230 |
| 240 // Returns true if sync_server_ is reachable. This method verifies that the | 231 // Returns true if sync_server_ is reachable. This method verifies that the |
| 241 // server is pingable and that traffic can be sent to and from it. | 232 // server is pingable and that traffic can be sent to and from it. |
| 242 virtual bool IsServerReachable(); | 233 virtual bool IsServerReachable(); |
| 243 | 234 |
| 244 // Returns true if user has been successfully authenticated. | 235 // Returns true if user has been successfully authenticated. |
| 245 virtual bool IsUserAuthenticated(); | 236 virtual bool IsUserAuthenticated(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 AutoLock lock(terminate_all_io_mutex_); | 273 AutoLock lock(terminate_all_io_mutex_); |
| 283 return terminate_all_io_; | 274 return terminate_all_io_; |
| 284 } | 275 } |
| 285 | 276 |
| 286 // Factory method to create a Post object we can use for communication with | 277 // Factory method to create a Post object we can use for communication with |
| 287 // the server. | 278 // the server. |
| 288 virtual Post* MakePost() { | 279 virtual Post* MakePost() { |
| 289 return NULL; // For testing. | 280 return NULL; // For testing. |
| 290 }; | 281 }; |
| 291 | 282 |
| 283 void set_client_id(const std::string& client_id) { |
| 284 DCHECK(client_id_.empty()); |
| 285 client_id_.assign(client_id); |
| 286 } |
| 287 |
| 292 void set_auth_token(const std::string& auth_token) { | 288 void set_auth_token(const std::string& auth_token) { |
| 293 // TODO(chron): Consider adding a message loop check here. | 289 // TODO(chron): Consider adding a message loop check here. |
| 294 AutoLock lock(auth_token_mutex_); | 290 AutoLock lock(auth_token_mutex_); |
| 295 auth_token_.assign(auth_token); | 291 auth_token_.assign(auth_token); |
| 296 } | 292 } |
| 297 | 293 |
| 298 const std::string auth_token() const { | 294 const std::string auth_token() const { |
| 299 AutoLock lock(auth_token_mutex_); | 295 AutoLock lock(auth_token_mutex_); |
| 300 return auth_token_; | 296 return auth_token_; |
| 301 } | 297 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 326 // Protects access to sync_server_, sync_server_port_ and use_ssl_: | 322 // Protects access to sync_server_, sync_server_port_ and use_ssl_: |
| 327 mutable Lock server_parameters_mutex_; | 323 mutable Lock server_parameters_mutex_; |
| 328 | 324 |
| 329 // The sync_server_ is the server that requests will be made to. | 325 // The sync_server_ is the server that requests will be made to. |
| 330 std::string sync_server_; | 326 std::string sync_server_; |
| 331 | 327 |
| 332 // The sync_server_port_ is the port that HTTP requests will be made on. | 328 // The sync_server_port_ is the port that HTTP requests will be made on. |
| 333 int sync_server_port_; | 329 int sync_server_port_; |
| 334 | 330 |
| 335 // The unique id of the user's client. | 331 // The unique id of the user's client. |
| 336 const std::string client_id_; | 332 std::string client_id_; |
| 337 | 333 |
| 338 // The user-agent string for HTTP. | 334 // The user-agent string for HTTP. |
| 339 std::string user_agent_; | 335 std::string user_agent_; |
| 340 | 336 |
| 341 // Indicates whether or not requests should be made using HTTPS. | 337 // Indicates whether or not requests should be made using HTTPS. |
| 342 bool use_ssl_; | 338 bool use_ssl_; |
| 343 | 339 |
| 344 // The paths we post to. | 340 // The paths we post to. |
| 345 mutable Lock path_mutex_; | 341 mutable Lock path_mutex_; |
| 346 std::string proto_sync_path_; | 342 std::string proto_sync_path_; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 bool FillMessageWithShareDetails(sync_pb::ClientToServerMessage* csm, | 376 bool FillMessageWithShareDetails(sync_pb::ClientToServerMessage* csm, |
| 381 syncable::DirectoryManager* manager, | 377 syncable::DirectoryManager* manager, |
| 382 const std::string& share); | 378 const std::string& share); |
| 383 | 379 |
| 384 } // namespace browser_sync | 380 } // namespace browser_sync |
| 385 | 381 |
| 386 std::ostream& operator<<(std::ostream& s, | 382 std::ostream& operator<<(std::ostream& s, |
| 387 const struct browser_sync::HttpResponse& hr); | 383 const struct browser_sync::HttpResponse& hr); |
| 388 | 384 |
| 389 #endif // CHROME_BROWSER_SYNC_ENGINE_NET_SERVER_CONNECTION_MANAGER_H_ | 385 #endif // CHROME_BROWSER_SYNC_ENGINE_NET_SERVER_CONNECTION_MANAGER_H_ |
| OLD | NEW |