Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Side by Side Diff: components/sync/core_impl/syncapi_server_connection_manager.h

Issue 2408463002: [Sync] Move network-related code from core/ to engine/net/. (Closed)
Patch Set: Use SyncServerConnectionManager instead of ServerConnectionManagerImpl. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_SYNC_CORE_IMPL_SYNCAPI_SERVER_CONNECTION_MANAGER_H_
6 #define COMPONENTS_SYNC_CORE_IMPL_SYNCAPI_SERVER_CONNECTION_MANAGER_H_
7
8 #include <memory>
9 #include <string>
10
11 #include "base/compiler_specific.h"
12 #include "base/gtest_prod_util.h"
13 #include "base/macros.h"
14 #include "components/sync/engine_impl/net/server_connection_manager.h"
15
16 namespace syncer {
17
18 class HttpPostProviderFactory;
19 class HttpPostProviderInterface;
20
21 // This provides HTTP Post functionality through the interface provided
22 // to the sync API by the application hosting the syncer backend.
23 class SyncAPIBridgedConnection : public ServerConnectionManager::Connection {
24 public:
25 SyncAPIBridgedConnection(ServerConnectionManager* scm,
26 HttpPostProviderFactory* factory);
27
28 ~SyncAPIBridgedConnection() override;
29
30 bool Init(const char* path,
31 const std::string& auth_token,
32 const std::string& payload,
33 HttpResponse* response) override;
34
35 void Abort() override;
36
37 private:
38 // Pointer to the factory we use for creating HttpPostProviders. We do not
39 // own |factory_|.
40 HttpPostProviderFactory* factory_;
41
42 HttpPostProviderInterface* post_provider_;
43
44 DISALLOW_COPY_AND_ASSIGN(SyncAPIBridgedConnection);
45 };
46
47 // A ServerConnectionManager subclass used by the syncapi layer. We use a
48 // subclass so that we can override MakePost() to generate a POST object using
49 // an instance of the HttpPostProviderFactory class.
50 class SyncAPIServerConnectionManager : public ServerConnectionManager {
51 public:
52 // Takes ownership of factory.
53 SyncAPIServerConnectionManager(const std::string& server,
54 int port,
55 bool use_ssl,
56 HttpPostProviderFactory* factory,
57 CancelationSignal* cancelation_signal);
58 ~SyncAPIServerConnectionManager() override;
59
60 // ServerConnectionManager overrides.
61 Connection* MakeConnection() override;
62
63 private:
64 FRIEND_TEST_ALL_PREFIXES(SyncAPIServerConnectionManagerTest,
65 VeryEarlyAbortPost);
66 FRIEND_TEST_ALL_PREFIXES(SyncAPIServerConnectionManagerTest, EarlyAbortPost);
67 FRIEND_TEST_ALL_PREFIXES(SyncAPIServerConnectionManagerTest, AbortPost);
68 FRIEND_TEST_ALL_PREFIXES(SyncAPIServerConnectionManagerTest,
69 FailPostWithTimedOut);
70
71 // A factory creating concrete HttpPostProviders for use whenever we need to
72 // issue a POST to sync servers.
73 std::unique_ptr<HttpPostProviderFactory> post_provider_factory_;
74
75 DISALLOW_COPY_AND_ASSIGN(SyncAPIServerConnectionManager);
76 };
77
78 } // namespace syncer
79
80 #endif // COMPONENTS_SYNC_CORE_IMPL_SYNCAPI_SERVER_CONNECTION_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698