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

Side by Side Diff: sync/internal_api/public/http_bridge.h

Issue 10698014: [Sync] Rename csync namespace to syncer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 years, 5 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef SYNC_INTERNAL_API_PUBLIC_HTTP_BRIDGE_H_ 5 #ifndef SYNC_INTERNAL_API_PUBLIC_HTTP_BRIDGE_H_
6 #define SYNC_INTERNAL_API_PUBLIC_HTTP_BRIDGE_H_ 6 #define SYNC_INTERNAL_API_PUBLIC_HTTP_BRIDGE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 20 matching lines...) Expand all
31 31
32 namespace browser_sync { 32 namespace browser_sync {
33 33
34 // A bridge between the syncer and Chromium HTTP layers. 34 // A bridge between the syncer and Chromium HTTP layers.
35 // Provides a way for the sync backend to use Chromium directly for HTTP 35 // Provides a way for the sync backend to use Chromium directly for HTTP
36 // requests rather than depending on a third party provider (e.g libcurl). 36 // requests rather than depending on a third party provider (e.g libcurl).
37 // This is a one-time use bridge. Create one for each request you want to make. 37 // This is a one-time use bridge. Create one for each request you want to make.
38 // It is RefCountedThreadSafe because it can PostTask to the io loop, and thus 38 // It is RefCountedThreadSafe because it can PostTask to the io loop, and thus
39 // needs to stick around across context switches, etc. 39 // needs to stick around across context switches, etc.
40 class HttpBridge : public base::RefCountedThreadSafe<HttpBridge>, 40 class HttpBridge : public base::RefCountedThreadSafe<HttpBridge>,
41 public csync::HttpPostProviderInterface, 41 public syncer::HttpPostProviderInterface,
42 public net::URLFetcherDelegate { 42 public net::URLFetcherDelegate {
43 public: 43 public:
44 // A request context used for HTTP requests bridged from the sync backend. 44 // A request context used for HTTP requests bridged from the sync backend.
45 // A bridged RequestContext has a dedicated in-memory cookie store and does 45 // A bridged RequestContext has a dedicated in-memory cookie store and does
46 // not use a cache. Thus the same type can be used for incognito mode. 46 // not use a cache. Thus the same type can be used for incognito mode.
47 class RequestContext : public net::URLRequestContext { 47 class RequestContext : public net::URLRequestContext {
48 public: 48 public:
49 // |baseline_context| is used to obtain the accept-language, 49 // |baseline_context| is used to obtain the accept-language,
50 // accept-charsets, and proxy service information for bridged requests. 50 // accept-charsets, and proxy service information for bridged requests.
51 // Typically |baseline_context| should be the net::URLRequestContext of the 51 // Typically |baseline_context| should be the net::URLRequestContext of the
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 const std::string user_agent_; 91 const std::string user_agent_;
92 92
93 // Lazily initialized by GetURLRequestContext(). 93 // Lazily initialized by GetURLRequestContext().
94 scoped_ptr<RequestContext> context_; 94 scoped_ptr<RequestContext> context_;
95 95
96 DISALLOW_COPY_AND_ASSIGN(RequestContextGetter); 96 DISALLOW_COPY_AND_ASSIGN(RequestContextGetter);
97 }; 97 };
98 98
99 explicit HttpBridge(RequestContextGetter* context); 99 explicit HttpBridge(RequestContextGetter* context);
100 100
101 // csync::HttpPostProvider implementation. 101 // syncer::HttpPostProvider implementation.
102 virtual void SetExtraRequestHeaders(const char* headers) OVERRIDE; 102 virtual void SetExtraRequestHeaders(const char* headers) OVERRIDE;
103 virtual void SetURL(const char* url, int port) OVERRIDE; 103 virtual void SetURL(const char* url, int port) OVERRIDE;
104 virtual void SetPostPayload(const char* content_type, int content_length, 104 virtual void SetPostPayload(const char* content_type, int content_length,
105 const char* content) OVERRIDE; 105 const char* content) OVERRIDE;
106 virtual bool MakeSynchronousPost(int* error_code, 106 virtual bool MakeSynchronousPost(int* error_code,
107 int* response_code) OVERRIDE; 107 int* response_code) OVERRIDE;
108 virtual void Abort() OVERRIDE; 108 virtual void Abort() OVERRIDE;
109 109
110 // WARNING: these response content methods are used to extract plain old data 110 // WARNING: these response content methods are used to extract plain old data
111 // and not null terminated strings, so you should make sure you have read 111 // and not null terminated strings, so you should make sure you have read
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 // This lock synchronizes use of state involved in the flow to fetch a URL 198 // This lock synchronizes use of state involved in the flow to fetch a URL
199 // using URLFetcher. Because we can Abort() from any thread, for example, 199 // using URLFetcher. Because we can Abort() from any thread, for example,
200 // this flow needs to be synchronized to gracefully clean up URLFetcher and 200 // this flow needs to be synchronized to gracefully clean up URLFetcher and
201 // return appropriate values in |error_code|. 201 // return appropriate values in |error_code|.
202 mutable base::Lock fetch_state_lock_; 202 mutable base::Lock fetch_state_lock_;
203 URLFetchState fetch_state_; 203 URLFetchState fetch_state_;
204 204
205 DISALLOW_COPY_AND_ASSIGN(HttpBridge); 205 DISALLOW_COPY_AND_ASSIGN(HttpBridge);
206 }; 206 };
207 207
208 class HttpBridgeFactory : public csync::HttpPostProviderFactory { 208 class HttpBridgeFactory : public syncer::HttpPostProviderFactory {
209 public: 209 public:
210 HttpBridgeFactory( 210 HttpBridgeFactory(
211 net::URLRequestContextGetter* baseline_context_getter, 211 net::URLRequestContextGetter* baseline_context_getter,
212 const std::string& user_agent); 212 const std::string& user_agent);
213 virtual ~HttpBridgeFactory(); 213 virtual ~HttpBridgeFactory();
214 214
215 // csync::HttpPostProviderFactory: 215 // syncer::HttpPostProviderFactory:
216 virtual csync::HttpPostProviderInterface* Create() OVERRIDE; 216 virtual syncer::HttpPostProviderInterface* Create() OVERRIDE;
217 virtual void Destroy(csync::HttpPostProviderInterface* http) OVERRIDE; 217 virtual void Destroy(syncer::HttpPostProviderInterface* http) OVERRIDE;
218 218
219 private: 219 private:
220 // This request context is built on top of the baseline context and shares 220 // This request context is built on top of the baseline context and shares
221 // common components. 221 // common components.
222 HttpBridge::RequestContextGetter* GetRequestContextGetter(); 222 HttpBridge::RequestContextGetter* GetRequestContextGetter();
223 223
224 const scoped_refptr<HttpBridge::RequestContextGetter> 224 const scoped_refptr<HttpBridge::RequestContextGetter>
225 request_context_getter_; 225 request_context_getter_;
226 226
227 DISALLOW_COPY_AND_ASSIGN(HttpBridgeFactory); 227 DISALLOW_COPY_AND_ASSIGN(HttpBridgeFactory);
228 }; 228 };
229 229
230 } // namespace browser_sync 230 } // namespace browser_sync
231 231
232 #endif // SYNC_INTERNAL_API_PUBLIC_HTTP_BRIDGE_H_ 232 #endif // SYNC_INTERNAL_API_PUBLIC_HTTP_BRIDGE_H_
OLDNEW
« no previous file with comments | « sync/internal_api/public/engine/sync_status.cc ('k') | sync/internal_api/public/http_post_provider_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698