OLD | NEW |
1 // Copyright (c) 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" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
15 #include "base/synchronization/waitable_event.h" | 15 #include "base/synchronization/waitable_event.h" |
16 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
17 #include "net/url_request/url_fetcher_delegate.h" | 17 #include "net/url_request/url_fetcher_delegate.h" |
18 #include "net/url_request/url_request_context.h" | 18 #include "net/url_request/url_request_context.h" |
19 #include "net/url_request/url_request_context_getter.h" | 19 #include "net/url_request/url_request_context_getter.h" |
| 20 #include "sync/base/sync_export.h" |
20 #include "sync/internal_api/public/http_post_provider_factory.h" | 21 #include "sync/internal_api/public/http_post_provider_factory.h" |
21 #include "sync/internal_api/public/http_post_provider_interface.h" | 22 #include "sync/internal_api/public/http_post_provider_interface.h" |
22 | 23 |
23 class MessageLoop; | 24 class MessageLoop; |
24 class HttpBridgeTest; | 25 class HttpBridgeTest; |
25 | 26 |
26 namespace net { | 27 namespace net { |
27 class HttpResponseHeaders; | 28 class HttpResponseHeaders; |
28 class HttpUserAgentSettings; | 29 class HttpUserAgentSettings; |
29 class URLFetcher; | 30 class URLFetcher; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 // This lock synchronizes use of state involved in the flow to fetch a URL | 197 // This lock synchronizes use of state involved in the flow to fetch a URL |
197 // using URLFetcher. Because we can Abort() from any thread, for example, | 198 // using URLFetcher. Because we can Abort() from any thread, for example, |
198 // this flow needs to be synchronized to gracefully clean up URLFetcher and | 199 // this flow needs to be synchronized to gracefully clean up URLFetcher and |
199 // return appropriate values in |error_code|. | 200 // return appropriate values in |error_code|. |
200 mutable base::Lock fetch_state_lock_; | 201 mutable base::Lock fetch_state_lock_; |
201 URLFetchState fetch_state_; | 202 URLFetchState fetch_state_; |
202 | 203 |
203 DISALLOW_COPY_AND_ASSIGN(HttpBridge); | 204 DISALLOW_COPY_AND_ASSIGN(HttpBridge); |
204 }; | 205 }; |
205 | 206 |
206 class HttpBridgeFactory : public HttpPostProviderFactory { | 207 class SYNC_EXPORT HttpBridgeFactory : public HttpPostProviderFactory { |
207 public: | 208 public: |
208 HttpBridgeFactory( | 209 HttpBridgeFactory( |
209 net::URLRequestContextGetter* baseline_context_getter, | 210 net::URLRequestContextGetter* baseline_context_getter, |
210 const std::string& user_agent); | 211 const std::string& user_agent); |
211 virtual ~HttpBridgeFactory(); | 212 virtual ~HttpBridgeFactory(); |
212 | 213 |
213 // HttpPostProviderFactory: | 214 // HttpPostProviderFactory: |
214 virtual HttpPostProviderInterface* Create() OVERRIDE; | 215 virtual HttpPostProviderInterface* Create() OVERRIDE; |
215 virtual void Destroy(HttpPostProviderInterface* http) OVERRIDE; | 216 virtual void Destroy(HttpPostProviderInterface* http) OVERRIDE; |
216 | 217 |
217 private: | 218 private: |
218 // This request context is built on top of the baseline context and shares | 219 // This request context is built on top of the baseline context and shares |
219 // common components. | 220 // common components. |
220 HttpBridge::RequestContextGetter* GetRequestContextGetter(); | 221 HttpBridge::RequestContextGetter* GetRequestContextGetter(); |
221 | 222 |
222 const scoped_refptr<HttpBridge::RequestContextGetter> | 223 const scoped_refptr<HttpBridge::RequestContextGetter> |
223 request_context_getter_; | 224 request_context_getter_; |
224 | 225 |
225 DISALLOW_COPY_AND_ASSIGN(HttpBridgeFactory); | 226 DISALLOW_COPY_AND_ASSIGN(HttpBridgeFactory); |
226 }; | 227 }; |
227 | 228 |
228 } // namespace syncer | 229 } // namespace syncer |
229 | 230 |
230 #endif // SYNC_INTERNAL_API_PUBLIC_HTTP_BRIDGE_H_ | 231 #endif // SYNC_INTERNAL_API_PUBLIC_HTTP_BRIDGE_H_ |
OLD | NEW |