| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_INTERNAL_API_SYNCAPI_SERVER_CONNECTION_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_INTERNAL_API_SYNCAPI_SERVER_CONNECTION_MANAGER_H_ |
| 6 #define CHROME_BROWSER_SYNC_INTERNAL_API_SYNCAPI_SERVER_CONNECTION_MANAGER_H_ | 6 #define CHROME_BROWSER_SYNC_INTERNAL_API_SYNCAPI_SERVER_CONNECTION_MANAGER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/gtest_prod_util.h" |
| 11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 12 #include "chrome/browser/sync/engine/net/server_connection_manager.h" | 13 #include "chrome/browser/sync/engine/net/server_connection_manager.h" |
| 13 | 14 |
| 14 namespace sync_api { | 15 namespace sync_api { |
| 15 | 16 |
| 16 class HttpPostProviderFactory; | 17 class HttpPostProviderFactory; |
| 18 class HttpPostProviderInterface; |
| 17 | 19 |
| 18 // This provides HTTP Post functionality through the interface provided | 20 // This provides HTTP Post functionality through the interface provided |
| 19 // to the sync API by the application hosting the syncer backend. | 21 // to the sync API by the application hosting the syncer backend. |
| 20 class SyncAPIBridgedPost | 22 class SyncAPIBridgedConnection |
| 21 : public browser_sync::ServerConnectionManager::Post { | 23 : public browser_sync::ServerConnectionManager::Connection { |
| 22 public: | 24 public: |
| 23 SyncAPIBridgedPost(browser_sync::ServerConnectionManager* scm, | 25 SyncAPIBridgedConnection(browser_sync::ServerConnectionManager* scm, |
| 24 HttpPostProviderFactory* factory); | 26 HttpPostProviderFactory* factory); |
| 25 | 27 |
| 26 virtual ~SyncAPIBridgedPost(); | 28 virtual ~SyncAPIBridgedConnection(); |
| 27 | 29 |
| 28 virtual bool Init(const char* path, | 30 virtual bool Init(const char* path, |
| 29 const std::string& auth_token, | 31 const std::string& auth_token, |
| 30 const std::string& payload, | 32 const std::string& payload, |
| 31 browser_sync::HttpResponse* response); | 33 browser_sync::HttpResponse* response) OVERRIDE; |
| 34 |
| 35 virtual void Abort() OVERRIDE; |
| 32 | 36 |
| 33 private: | 37 private: |
| 34 // Pointer to the factory we use for creating HttpPostProviders. We do not | 38 // Pointer to the factory we use for creating HttpPostProviders. We do not |
| 35 // own |factory_|. | 39 // own |factory_|. |
| 36 HttpPostProviderFactory* factory_; | 40 HttpPostProviderFactory* factory_; |
| 37 | 41 |
| 38 DISALLOW_COPY_AND_ASSIGN(SyncAPIBridgedPost); | 42 HttpPostProviderInterface* post_provider_; |
| 43 |
| 44 DISALLOW_COPY_AND_ASSIGN(SyncAPIBridgedConnection); |
| 39 }; | 45 }; |
| 40 | 46 |
| 41 // A ServerConnectionManager subclass used by the syncapi layer. We use a | 47 // 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 | 48 // subclass so that we can override MakePost() to generate a POST object using |
| 43 // an instance of the HttpPostProviderFactory class. | 49 // an instance of the HttpPostProviderFactory class. |
| 44 class SyncAPIServerConnectionManager | 50 class SyncAPIServerConnectionManager |
| 45 : public browser_sync::ServerConnectionManager { | 51 : public browser_sync::ServerConnectionManager { |
| 46 public: | 52 public: |
| 47 // Takes ownership of factory. | 53 // Takes ownership of factory. |
| 48 SyncAPIServerConnectionManager(const std::string& server, | 54 SyncAPIServerConnectionManager(const std::string& server, |
| 49 int port, | 55 int port, |
| 50 bool use_ssl, | 56 bool use_ssl, |
| 51 const std::string& client_version, | 57 const std::string& client_version, |
| 52 HttpPostProviderFactory* factory); | 58 HttpPostProviderFactory* factory); |
| 53 virtual ~SyncAPIServerConnectionManager(); | 59 virtual ~SyncAPIServerConnectionManager(); |
| 54 | 60 |
| 55 protected: | 61 // ServerConnectionManager overrides. |
| 56 virtual Post* MakePost(); | 62 virtual Connection* MakeConnection() OVERRIDE; |
| 57 | 63 |
| 58 private: | 64 private: |
| 65 FRIEND_TEST_ALL_PREFIXES(SyncAPIServerConnectionManagerTest, EarlyAbortPost); |
| 66 FRIEND_TEST_ALL_PREFIXES(SyncAPIServerConnectionManagerTest, AbortPost); |
| 67 |
| 59 // A factory creating concrete HttpPostProviders for use whenever we need to | 68 // A factory creating concrete HttpPostProviders for use whenever we need to |
| 60 // issue a POST to sync servers. | 69 // issue a POST to sync servers. |
| 61 scoped_ptr<HttpPostProviderFactory> post_provider_factory_; | 70 scoped_ptr<HttpPostProviderFactory> post_provider_factory_; |
| 62 | 71 |
| 63 DISALLOW_COPY_AND_ASSIGN(SyncAPIServerConnectionManager); | 72 DISALLOW_COPY_AND_ASSIGN(SyncAPIServerConnectionManager); |
| 64 }; | 73 }; |
| 65 | 74 |
| 66 } // namespace sync_api | 75 } // namespace sync_api |
| 67 | 76 |
| 68 #endif // CHROME_BROWSER_SYNC_INTERNAL_API_SYNCAPI_SERVER_CONNECTION_MANAGER_H_ | 77 #endif // CHROME_BROWSER_SYNC_INTERNAL_API_SYNCAPI_SERVER_CONNECTION_MANAGER_H_ |
| OLD | NEW |