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

Side by Side Diff: chrome/browser/sync/engine/net/syncapi_server_connection_manager.h

Issue 194065: Initial commit of sync engine code to browser/sync.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Fixes to gtest include path, reverted syncapi. Created 11 years, 3 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 | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2009 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 CHROME_BROWSER_SYNC_ENGINE_NET_SYNCAPI_SERVER_CONNECTION_MANAGER_H_
6 #define CHROME_BROWSER_SYNC_ENGINE_NET_SYNCAPI_SERVER_CONNECTION_MANAGER_H_
7
8 #include <string>
9
10 #include "chrome/browser/sync/engine/net/server_connection_manager.h"
11
12 namespace sync_api {
13
14 class HttpPostProviderFactory;
15
16 // This provides HTTP Post functionality through the interface provided
17 // to the sync API by the application hosting the syncer backend.
18 class SyncAPIBridgedPost :
19 public browser_sync::ServerConnectionManager::Post {
20 public:
21 SyncAPIBridgedPost(browser_sync::ServerConnectionManager* scm,
22 HttpPostProviderFactory* factory)
23 : Post(scm), factory_(factory) {
24 }
25
26 virtual ~SyncAPIBridgedPost() { }
27
28 virtual bool Init(const char* path,
29 const std::string& auth_token,
30 const std::string& payload,
31 browser_sync::HttpResponse* response);
32
33 private:
34 // Pointer to the factory we use for creating HttpPostProviders. We do not
35 // own |factory_|.
36 HttpPostProviderFactory* factory_;
37
38 DISALLOW_COPY_AND_ASSIGN(SyncAPIBridgedPost);
39 };
40
41 // A ServerConnectionManager subclass used by the syncapi layer. We use a
42 // subclass so that we can override MakePost() to generate a POST object using
43 // an instance of the HttpPostProviderFactory class.
44 class SyncAPIServerConnectionManager :
45 public browser_sync::ServerConnectionManager {
46 public:
47 SyncAPIServerConnectionManager(const std::string& server,
48 int port,
49 bool use_ssl,
50 const std::string& client_version,
51 const std::string& client_id)
52 : ServerConnectionManager(server, port, use_ssl, client_version,
53 client_id),
54 post_provider_factory_(NULL) {
55 }
56
57 virtual ~SyncAPIServerConnectionManager();
58
59 // This method gives ownership of |factory| to |this|.
60 void SetHttpPostProviderFactory(HttpPostProviderFactory* factory);
61 protected:
62 virtual Post* MakePost() {
63 return new SyncAPIBridgedPost(this, post_provider_factory_);
64 }
65 private:
66 // A factory creating concrete HttpPostProviders for use whenever we need to
67 // issue a POST to sync servers.
68 HttpPostProviderFactory* post_provider_factory_;
69
70 DISALLOW_COPY_AND_ASSIGN(SyncAPIServerConnectionManager);
71 };
72
73 } // namespace sync_api
74
75 #endif // CHROME_BROWSER_SYNC_ENGINE_NET_SYNCAPI_SERVER_CONNECTION_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698