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

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

Issue 11624037: [sync] Componentize sync: Part 6: Add more SYNC_EXPORTs to files in src/sync/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase (no code changes) Created 7 years, 11 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 2012 The Chromium Authors. All rights reserved. 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 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 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 20 matching lines...) Expand all
31 } 31 }
32 32
33 namespace syncer { 33 namespace syncer {
34 34
35 // A bridge between the syncer and Chromium HTTP layers. 35 // A bridge between the syncer and Chromium HTTP layers.
36 // Provides a way for the sync backend to use Chromium directly for HTTP 36 // Provides a way for the sync backend to use Chromium directly for HTTP
37 // requests rather than depending on a third party provider (e.g libcurl). 37 // requests rather than depending on a third party provider (e.g libcurl).
38 // This is a one-time use bridge. Create one for each request you want to make. 38 // This is a one-time use bridge. Create one for each request you want to make.
39 // It is RefCountedThreadSafe because it can PostTask to the io loop, and thus 39 // It is RefCountedThreadSafe because it can PostTask to the io loop, and thus
40 // needs to stick around across context switches, etc. 40 // needs to stick around across context switches, etc.
41 class HttpBridge : public base::RefCountedThreadSafe<HttpBridge>, 41 class SYNC_EXPORT_PRIVATE HttpBridge
42 public HttpPostProviderInterface, 42 : public base::RefCountedThreadSafe<HttpBridge>,
43 public net::URLFetcherDelegate { 43 public HttpPostProviderInterface,
44 public net::URLFetcherDelegate {
44 public: 45 public:
46 friend class SyncHttpBridgeTest;
47
45 // A request context used for HTTP requests bridged from the sync backend. 48 // A request context used for HTTP requests bridged from the sync backend.
46 // A bridged RequestContext has a dedicated in-memory cookie store and does 49 // A bridged RequestContext has a dedicated in-memory cookie store and does
47 // not use a cache. Thus the same type can be used for incognito mode. 50 // not use a cache. Thus the same type can be used for incognito mode.
48 class RequestContext : public net::URLRequestContext { 51 class RequestContext : public net::URLRequestContext {
49 public: 52 public:
50 // |baseline_context| is used to obtain the accept-language, 53 // |baseline_context| is used to obtain the accept-language,
51 // accept-charsets, and proxy service information for bridged requests. 54 // accept-charsets, and proxy service information for bridged requests.
52 // Typically |baseline_context| should be the net::URLRequestContext of the 55 // Typically |baseline_context| should be the net::URLRequestContext of the
53 // currently active profile. 56 // currently active profile.
54 RequestContext( 57 RequestContext(
55 net::URLRequestContext* baseline_context, 58 net::URLRequestContext* baseline_context,
56 const scoped_refptr<base::SingleThreadTaskRunner>& 59 const scoped_refptr<base::SingleThreadTaskRunner>&
57 network_task_runner, 60 network_task_runner,
58 const std::string& user_agent); 61 const std::string& user_agent);
59 62
60 // The destructor MUST be called on the IO thread. 63 // The destructor MUST be called on the IO thread.
61 virtual ~RequestContext(); 64 virtual ~RequestContext();
62 65
63 private: 66 private:
64 net::URLRequestContext* const baseline_context_; 67 net::URLRequestContext* const baseline_context_;
65 const scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; 68 const scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_;
66 scoped_ptr<net::HttpUserAgentSettings> http_user_agent_settings_; 69 scoped_ptr<net::HttpUserAgentSettings> http_user_agent_settings_;
67 70
68 DISALLOW_COPY_AND_ASSIGN(RequestContext); 71 DISALLOW_COPY_AND_ASSIGN(RequestContext);
69 }; 72 };
70 73
71 // Lazy-getter for RequestContext objects. 74 // Lazy-getter for RequestContext objects.
72 class RequestContextGetter : public net::URLRequestContextGetter { 75 class SYNC_EXPORT_PRIVATE RequestContextGetter
76 : public net::URLRequestContextGetter {
73 public: 77 public:
74 RequestContextGetter( 78 RequestContextGetter(
75 net::URLRequestContextGetter* baseline_context_getter, 79 net::URLRequestContextGetter* baseline_context_getter,
76 const std::string& user_agent); 80 const std::string& user_agent);
77 81
78 // net::URLRequestContextGetter implementation. 82 // net::URLRequestContextGetter implementation.
79 virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE; 83 virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE;
80 virtual scoped_refptr<base::SingleThreadTaskRunner> 84 virtual scoped_refptr<base::SingleThreadTaskRunner>
81 GetNetworkTaskRunner() const OVERRIDE; 85 GetNetworkTaskRunner() const OVERRIDE;
82 86
(...skipping 28 matching lines...) Expand all
111 // GetResponseContentLength() characters when using GetResponseContent. e.g 115 // GetResponseContentLength() characters when using GetResponseContent. e.g
112 // string r(b->GetResponseContent(), b->GetResponseContentLength()). 116 // string r(b->GetResponseContent(), b->GetResponseContentLength()).
113 virtual int GetResponseContentLength() const OVERRIDE; 117 virtual int GetResponseContentLength() const OVERRIDE;
114 virtual const char* GetResponseContent() const OVERRIDE; 118 virtual const char* GetResponseContent() const OVERRIDE;
115 virtual const std::string GetResponseHeaderValue( 119 virtual const std::string GetResponseHeaderValue(
116 const std::string& name) const OVERRIDE; 120 const std::string& name) const OVERRIDE;
117 121
118 // net::URLFetcherDelegate implementation. 122 // net::URLFetcherDelegate implementation.
119 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; 123 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
120 124
121 #if defined(UNIT_TEST) 125 net::URLRequestContextGetter* GetRequestContextGetterForTest() const;
122 net::URLRequestContextGetter* GetRequestContextGetter() const {
123 return context_getter_for_request_;
124 }
125 #endif
126 126
127 protected: 127 protected:
128 friend class base::RefCountedThreadSafe<HttpBridge>; 128 friend class base::RefCountedThreadSafe<HttpBridge>;
129 129
130 virtual ~HttpBridge(); 130 virtual ~HttpBridge();
131 131
132 // Protected virtual so the unit test can override to shunt network requests. 132 // Protected virtual so the unit test can override to shunt network requests.
133 virtual void MakeAsynchronousPost(); 133 virtual void MakeAsynchronousPost();
134 134
135 private: 135 private:
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 222
223 const scoped_refptr<HttpBridge::RequestContextGetter> 223 const scoped_refptr<HttpBridge::RequestContextGetter>
224 request_context_getter_; 224 request_context_getter_;
225 225
226 DISALLOW_COPY_AND_ASSIGN(HttpBridgeFactory); 226 DISALLOW_COPY_AND_ASSIGN(HttpBridgeFactory);
227 }; 227 };
228 228
229 } // namespace syncer 229 } // namespace syncer
230 230
231 #endif // SYNC_INTERNAL_API_PUBLIC_HTTP_BRIDGE_H_ 231 #endif // SYNC_INTERNAL_API_PUBLIC_HTTP_BRIDGE_H_
OLDNEW
« no previous file with comments | « sync/internal_api/public/engine/polling_constants.h ('k') | sync/internal_api/public/http_post_provider_interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698