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