| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_SYNCAPI_SERVER_CONNECTION_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_ENGINE_NET_SYNCAPI_SERVER_CONNECTION_MANAGER_H_ |
| 6 #define CHROME_BROWSER_SYNC_ENGINE_NET_SYNCAPI_SERVER_CONNECTION_MANAGER_H_ | 6 #define CHROME_BROWSER_SYNC_ENGINE_NET_SYNCAPI_SERVER_CONNECTION_MANAGER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/scoped_ptr.h" |
| 10 #include "chrome/browser/sync/engine/net/server_connection_manager.h" | 11 #include "chrome/browser/sync/engine/net/server_connection_manager.h" |
| 11 | 12 |
| 12 namespace sync_api { | 13 namespace sync_api { |
| 13 | 14 |
| 14 class HttpPostProviderFactory; | 15 class HttpPostProviderFactory; |
| 15 | 16 |
| 16 // This provides HTTP Post functionality through the interface provided | 17 // This provides HTTP Post functionality through the interface provided |
| 17 // to the sync API by the application hosting the syncer backend. | 18 // to the sync API by the application hosting the syncer backend. |
| 18 class SyncAPIBridgedPost | 19 class SyncAPIBridgedPost |
| 19 : public browser_sync::ServerConnectionManager::Post { | 20 : public browser_sync::ServerConnectionManager::Post { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 37 | 38 |
| 38 DISALLOW_COPY_AND_ASSIGN(SyncAPIBridgedPost); | 39 DISALLOW_COPY_AND_ASSIGN(SyncAPIBridgedPost); |
| 39 }; | 40 }; |
| 40 | 41 |
| 41 // A ServerConnectionManager subclass used by the syncapi layer. We use a | 42 // A ServerConnectionManager subclass used by the syncapi layer. We use a |
| 42 // subclass so that we can override MakePost() to generate a POST object using | 43 // subclass so that we can override MakePost() to generate a POST object using |
| 43 // an instance of the HttpPostProviderFactory class. | 44 // an instance of the HttpPostProviderFactory class. |
| 44 class SyncAPIServerConnectionManager | 45 class SyncAPIServerConnectionManager |
| 45 : public browser_sync::ServerConnectionManager { | 46 : public browser_sync::ServerConnectionManager { |
| 46 public: | 47 public: |
| 48 // Takes ownership of factory. |
| 47 SyncAPIServerConnectionManager(const std::string& server, | 49 SyncAPIServerConnectionManager(const std::string& server, |
| 48 int port, | 50 int port, |
| 49 bool use_ssl, | 51 bool use_ssl, |
| 50 const std::string& client_version, | 52 const std::string& client_version, |
| 51 const std::string& client_id) | 53 const std::string& client_id, |
| 54 HttpPostProviderFactory* factory) |
| 52 : ServerConnectionManager(server, port, use_ssl, client_version, | 55 : ServerConnectionManager(server, port, use_ssl, client_version, |
| 53 client_id), | 56 client_id), |
| 54 post_provider_factory_(NULL) { | 57 post_provider_factory_(factory) { |
| 58 DCHECK(post_provider_factory_.get()); |
| 55 } | 59 } |
| 56 | 60 |
| 57 virtual ~SyncAPIServerConnectionManager(); | 61 virtual ~SyncAPIServerConnectionManager(); |
| 58 | |
| 59 // This method gives ownership of |factory| to |this|. | |
| 60 void SetHttpPostProviderFactory(HttpPostProviderFactory* factory); | |
| 61 protected: | 62 protected: |
| 62 virtual Post* MakePost() { | 63 virtual Post* MakePost() { |
| 63 return new SyncAPIBridgedPost(this, post_provider_factory_); | 64 return new SyncAPIBridgedPost(this, post_provider_factory_.get()); |
| 64 } | 65 } |
| 65 private: | 66 private: |
| 66 // A factory creating concrete HttpPostProviders for use whenever we need to | 67 // A factory creating concrete HttpPostProviders for use whenever we need to |
| 67 // issue a POST to sync servers. | 68 // issue a POST to sync servers. |
| 68 HttpPostProviderFactory* post_provider_factory_; | 69 scoped_ptr<HttpPostProviderFactory> post_provider_factory_; |
| 69 | 70 |
| 70 DISALLOW_COPY_AND_ASSIGN(SyncAPIServerConnectionManager); | 71 DISALLOW_COPY_AND_ASSIGN(SyncAPIServerConnectionManager); |
| 71 }; | 72 }; |
| 72 | 73 |
| 73 } // namespace sync_api | 74 } // namespace sync_api |
| 74 | 75 |
| 75 #endif // CHROME_BROWSER_SYNC_ENGINE_NET_SYNCAPI_SERVER_CONNECTION_MANAGER_H_ | 76 #endif // CHROME_BROWSER_SYNC_ENGINE_NET_SYNCAPI_SERVER_CONNECTION_MANAGER_H_ |
| OLD | NEW |