Chromium Code Reviews| Index: components/sync/engine_impl/net/server_connection_manager_impl.h |
| diff --git a/components/sync/engine_impl/net/server_connection_manager_impl.h b/components/sync/engine_impl/net/server_connection_manager_impl.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9d1abc28892c24222e63c62ada1f68ee2db2d859 |
| --- /dev/null |
| +++ b/components/sync/engine_impl/net/server_connection_manager_impl.h |
| @@ -0,0 +1,78 @@ |
| +// Copyright 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef COMPONENTS_SYNC_ENGINE_IMPL_NET_SERVER_CONNECTION_MANAGER_IMPL_H_ |
| +#define COMPONENTS_SYNC_ENGINE_IMPL_NET_SERVER_CONNECTION_MANAGER_IMPL_H_ |
| + |
| +#include <memory> |
| +#include <string> |
| + |
| +#include "base/compiler_specific.h" |
| +#include "base/gtest_prod_util.h" |
| +#include "base/macros.h" |
| +#include "components/sync/engine_impl/net/server_connection_manager.h" |
| + |
| +namespace syncer { |
| + |
| +class HttpPostProviderFactory; |
| +class HttpPostProviderInterface; |
| + |
| +// This provides HTTP Post functionality through the interface provided |
| +// by the application hosting the syncer backend. |
| +class SyncBridgedConnection : public ServerConnectionManager::Connection { |
| + public: |
| + SyncBridgedConnection(ServerConnectionManager* scm, |
| + HttpPostProviderFactory* factory); |
| + |
| + ~SyncBridgedConnection() override; |
| + |
| + bool Init(const char* path, |
| + const std::string& auth_token, |
| + const std::string& payload, |
| + HttpResponse* response) override; |
| + |
| + void Abort() override; |
| + |
| + private: |
| + // Pointer to the factory we use for creating HttpPostProviders. We do not |
| + // own |factory_|. |
| + HttpPostProviderFactory* factory_; |
| + |
| + HttpPostProviderInterface* post_provider_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(SyncBridgedConnection); |
| +}; |
| + |
| +// A ServerConnectionManager subclass that generates a POST object using an |
| +// instance of the HttpPostProviderFactory class. |
| +class ServerConnectionManagerImpl : public ServerConnectionManager { |
|
pavely
2016/10/10 18:54:06
Usually class is named Impl if base class is an in
maxbogue
2016/10/10 20:36:48
Switched to SyncServerConnectionManager instead, P
|
| + public: |
| + // Takes ownership of factory. |
| + ServerConnectionManagerImpl(const std::string& server, |
| + int port, |
| + bool use_ssl, |
| + HttpPostProviderFactory* factory, |
| + CancelationSignal* cancelation_signal); |
| + ~ServerConnectionManagerImpl() override; |
| + |
| + // ServerConnectionManager overrides. |
| + Connection* MakeConnection() override; |
| + |
| + private: |
| + FRIEND_TEST_ALL_PREFIXES(ServerConnectionManagerImplTest, VeryEarlyAbortPost); |
| + FRIEND_TEST_ALL_PREFIXES(ServerConnectionManagerImplTest, EarlyAbortPost); |
| + FRIEND_TEST_ALL_PREFIXES(ServerConnectionManagerImplTest, AbortPost); |
| + FRIEND_TEST_ALL_PREFIXES(ServerConnectionManagerImplTest, |
| + FailPostWithTimedOut); |
| + |
| + // A factory creating concrete HttpPostProviders for use whenever we need to |
| + // issue a POST to sync servers. |
| + std::unique_ptr<HttpPostProviderFactory> post_provider_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ServerConnectionManagerImpl); |
| +}; |
| + |
| +} // namespace syncer |
| + |
| +#endif // COMPONENTS_SYNC_ENGINE_IMPL_NET_SERVER_CONNECTION_MANAGER_IMPL_H_ |