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

Side by Side Diff: components/sync/engine_impl/net/sync_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_ENGINE_IMPL_NET_SYNC_SERVER_CONNECTION_MANAGER_H_
6 #define COMPONENTS_SYNC_ENGINE_IMPL_NET_SYNC_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 // by the application hosting the syncer backend.
23 class SyncBridgedConnection : public ServerConnectionManager::Connection {
24 public:
25 SyncBridgedConnection(ServerConnectionManager* scm,
26 HttpPostProviderFactory* factory);
27
28 ~SyncBridgedConnection() 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(SyncBridgedConnection);
45 };
46
47 // A ServerConnectionManager subclass that generates a POST object using an
48 // instance of the HttpPostProviderFactory class.
49 class SyncServerConnectionManager : public ServerConnectionManager {
50 public:
51 // Takes ownership of factory.
52 SyncServerConnectionManager(const std::string& server,
53 int port,
54 bool use_ssl,
55 HttpPostProviderFactory* factory,
56 CancelationSignal* cancelation_signal);
57 ~SyncServerConnectionManager() override;
58
59 // ServerConnectionManager overrides.
60 Connection* MakeConnection() override;
61
62 private:
63 FRIEND_TEST_ALL_PREFIXES(SyncServerConnectionManagerTest, VeryEarlyAbortPost);
64 FRIEND_TEST_ALL_PREFIXES(SyncServerConnectionManagerTest, EarlyAbortPost);
65 FRIEND_TEST_ALL_PREFIXES(SyncServerConnectionManagerTest, AbortPost);
66 FRIEND_TEST_ALL_PREFIXES(SyncServerConnectionManagerTest,
67 FailPostWithTimedOut);
68
69 // A factory creating concrete HttpPostProviders for use whenever we need to
70 // issue a POST to sync servers.
71 std::unique_ptr<HttpPostProviderFactory> post_provider_factory_;
72
73 DISALLOW_COPY_AND_ASSIGN(SyncServerConnectionManager);
74 };
75
76 } // namespace syncer
77
78 #endif // COMPONENTS_SYNC_ENGINE_IMPL_NET_SYNC_SERVER_CONNECTION_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698