| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <iosfwd> | 9 #include <iosfwd> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 std::string buffer_; | 169 std::string buffer_; |
| 170 ServerConnectionManager* scm_; | 170 ServerConnectionManager* scm_; |
| 171 | 171 |
| 172 private: | 172 private: |
| 173 int ReadResponse(void* buffer, int length); | 173 int ReadResponse(void* buffer, int length); |
| 174 int ReadResponse(std::string* buffer, int length); | 174 int ReadResponse(std::string* buffer, int length); |
| 175 }; | 175 }; |
| 176 | 176 |
| 177 ServerConnectionManager(const std::string& server, | 177 ServerConnectionManager(const std::string& server, |
| 178 int port, | 178 int port, |
| 179 bool use_ssl, | 179 bool use_ssl); |
| 180 const std::string& user_agent); | |
| 181 | 180 |
| 182 virtual ~ServerConnectionManager(); | 181 virtual ~ServerConnectionManager(); |
| 183 | 182 |
| 184 // POSTS buffer_in and reads a response into buffer_out. Uses our currently | 183 // POSTS buffer_in and reads a response into buffer_out. Uses our currently |
| 185 // set auth token in our headers. | 184 // set auth token in our headers. |
| 186 // | 185 // |
| 187 // Returns true if executed successfully. | 186 // Returns true if executed successfully. |
| 188 virtual bool PostBufferWithCachedAuth(PostBufferParams* params, | 187 virtual bool PostBufferWithCachedAuth(PostBufferParams* params, |
| 189 ScopedServerStatusWatcher* watcher); | 188 ScopedServerStatusWatcher* watcher); |
| 190 | 189 |
| 191 void AddListener(ServerConnectionEventListener* listener); | 190 void AddListener(ServerConnectionEventListener* listener); |
| 192 void RemoveListener(ServerConnectionEventListener* listener); | 191 void RemoveListener(ServerConnectionEventListener* listener); |
| 193 | 192 |
| 194 inline std::string user_agent() const { return user_agent_; } | |
| 195 | |
| 196 inline HttpResponse::ServerConnectionCode server_status() const { | 193 inline HttpResponse::ServerConnectionCode server_status() const { |
| 197 DCHECK(thread_checker_.CalledOnValidThread()); | 194 DCHECK(thread_checker_.CalledOnValidThread()); |
| 198 return server_status_; | 195 return server_status_; |
| 199 } | 196 } |
| 200 | 197 |
| 201 const std::string client_id() const { return client_id_; } | 198 const std::string client_id() const { return client_id_; } |
| 202 | 199 |
| 203 // Returns the current server parameters in server_url, port and use_ssl. | 200 // Returns the current server parameters in server_url, port and use_ssl. |
| 204 void GetServerParameters(std::string* server_url, | 201 void GetServerParameters(std::string* server_url, |
| 205 int* port, | 202 int* port, |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 | 277 |
| 281 // The sync_server_ is the server that requests will be made to. | 278 // The sync_server_ is the server that requests will be made to. |
| 282 std::string sync_server_; | 279 std::string sync_server_; |
| 283 | 280 |
| 284 // The sync_server_port_ is the port that HTTP requests will be made on. | 281 // The sync_server_port_ is the port that HTTP requests will be made on. |
| 285 int sync_server_port_; | 282 int sync_server_port_; |
| 286 | 283 |
| 287 // The unique id of the user's client. | 284 // The unique id of the user's client. |
| 288 std::string client_id_; | 285 std::string client_id_; |
| 289 | 286 |
| 290 // The user-agent string for HTTP. | |
| 291 std::string user_agent_; | |
| 292 | |
| 293 // Indicates whether or not requests should be made using HTTPS. | 287 // Indicates whether or not requests should be made using HTTPS. |
| 294 bool use_ssl_; | 288 bool use_ssl_; |
| 295 | 289 |
| 296 // The paths we post to. | 290 // The paths we post to. |
| 297 std::string proto_sync_path_; | 291 std::string proto_sync_path_; |
| 298 std::string get_time_path_; | 292 std::string get_time_path_; |
| 299 | 293 |
| 300 // The auth token to use in authenticated requests. | 294 // The auth token to use in authenticated requests. |
| 301 std::string auth_token_; | 295 std::string auth_token_; |
| 302 | 296 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 // settings. | 344 // settings. |
| 351 bool FillMessageWithShareDetails(sync_pb::ClientToServerMessage* csm, | 345 bool FillMessageWithShareDetails(sync_pb::ClientToServerMessage* csm, |
| 352 syncable::Directory* manager, | 346 syncable::Directory* manager, |
| 353 const std::string& share); | 347 const std::string& share); |
| 354 | 348 |
| 355 std::ostream& operator<<(std::ostream& s, const struct HttpResponse& hr); | 349 std::ostream& operator<<(std::ostream& s, const struct HttpResponse& hr); |
| 356 | 350 |
| 357 } // namespace csync | 351 } // namespace csync |
| 358 | 352 |
| 359 #endif // SYNC_ENGINE_NET_SERVER_CONNECTION_MANAGER_H_ | 353 #endif // SYNC_ENGINE_NET_SERVER_CONNECTION_MANAGER_H_ |
| OLD | NEW |