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

Side by Side Diff: sync/internal_api/syncapi_server_connection_manager.h

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 4 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 SYNC_INTERNAL_API_SYNCAPI_SERVER_CONNECTION_MANAGER_H_
6 #define SYNC_INTERNAL_API_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 "sync/base/sync_export.h"
15 #include "sync/engine/net/server_connection_manager.h"
16
17 namespace syncer {
18
19 class HttpPostProviderFactory;
20 class HttpPostProviderInterface;
21
22 // This provides HTTP Post functionality through the interface provided
23 // to the sync API by the application hosting the syncer backend.
24 class SyncAPIBridgedConnection : public ServerConnectionManager::Connection {
25 public:
26 SyncAPIBridgedConnection(ServerConnectionManager* scm,
27 HttpPostProviderFactory* factory);
28
29 ~SyncAPIBridgedConnection() override;
30
31 bool Init(const char* path,
32 const std::string& auth_token,
33 const std::string& payload,
34 HttpResponse* response) override;
35
36 void Abort() override;
37
38 private:
39 // Pointer to the factory we use for creating HttpPostProviders. We do not
40 // own |factory_|.
41 HttpPostProviderFactory* factory_;
42
43 HttpPostProviderInterface* post_provider_;
44
45 DISALLOW_COPY_AND_ASSIGN(SyncAPIBridgedConnection);
46 };
47
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
50 // an instance of the HttpPostProviderFactory class.
51 class SYNC_EXPORT SyncAPIServerConnectionManager
52 : public ServerConnectionManager {
53 public:
54 // Takes ownership of factory.
55 SyncAPIServerConnectionManager(const std::string& server,
56 int port,
57 bool use_ssl,
58 HttpPostProviderFactory* factory,
59 CancelationSignal* cancelation_signal);
60 ~SyncAPIServerConnectionManager() override;
61
62 // ServerConnectionManager overrides.
63 Connection* MakeConnection() override;
64
65 private:
66 FRIEND_TEST_ALL_PREFIXES(SyncAPIServerConnectionManagerTest,
67 VeryEarlyAbortPost);
68 FRIEND_TEST_ALL_PREFIXES(SyncAPIServerConnectionManagerTest, EarlyAbortPost);
69 FRIEND_TEST_ALL_PREFIXES(SyncAPIServerConnectionManagerTest, AbortPost);
70 FRIEND_TEST_ALL_PREFIXES(SyncAPIServerConnectionManagerTest,
71 FailPostWithTimedOut);
72
73 // A factory creating concrete HttpPostProviders for use whenever we need to
74 // issue a POST to sync servers.
75 std::unique_ptr<HttpPostProviderFactory> post_provider_factory_;
76
77 DISALLOW_COPY_AND_ASSIGN(SyncAPIServerConnectionManager);
78 };
79
80 } // namespace syncer
81
82 #endif // SYNC_INTERNAL_API_SYNCAPI_SERVER_CONNECTION_MANAGER_H_
OLDNEW
« no previous file with comments | « sync/internal_api/syncapi_internal.cc ('k') | sync/internal_api/syncapi_server_connection_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698