| OLD | NEW |
| 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 | 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/internal_api/public/http_post_provider_factory.h" | 20 #include "sync/internal_api/public/http_post_provider_factory.h" |
| 21 #include "sync/internal_api/public/http_post_provider_interface.h" | 21 #include "sync/internal_api/public/http_post_provider_interface.h" |
| 22 | 22 |
| 23 class MessageLoop; | 23 class MessageLoop; |
| 24 class HttpBridgeTest; | 24 class HttpBridgeTest; |
| 25 | 25 |
| 26 namespace net { | 26 namespace net { |
| 27 class HttpResponseHeaders; | 27 class HttpResponseHeaders; |
| 28 class HttpUserAgentSettings; |
| 28 class URLFetcher; | 29 class URLFetcher; |
| 29 } | 30 } |
| 30 | 31 |
| 31 namespace syncer { | 32 namespace syncer { |
| 32 | 33 |
| 33 // A bridge between the syncer and Chromium HTTP layers. | 34 // A bridge between the syncer and Chromium HTTP layers. |
| 34 // 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 |
| 35 // 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). |
| 36 // 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. |
| 37 // 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 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 51 // currently active profile. | 52 // currently active profile. |
| 52 RequestContext( | 53 RequestContext( |
| 53 net::URLRequestContext* baseline_context, | 54 net::URLRequestContext* baseline_context, |
| 54 const scoped_refptr<base::SingleThreadTaskRunner>& | 55 const scoped_refptr<base::SingleThreadTaskRunner>& |
| 55 network_task_runner, | 56 network_task_runner, |
| 56 const std::string& user_agent); | 57 const std::string& user_agent); |
| 57 | 58 |
| 58 // The destructor MUST be called on the IO thread. | 59 // The destructor MUST be called on the IO thread. |
| 59 virtual ~RequestContext(); | 60 virtual ~RequestContext(); |
| 60 | 61 |
| 61 virtual const std::string& GetUserAgent(const GURL& url) const OVERRIDE; | |
| 62 | |
| 63 private: | 62 private: |
| 64 net::URLRequestContext* const baseline_context_; | 63 net::URLRequestContext* const baseline_context_; |
| 65 const scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; | 64 const scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; |
| 66 const std::string user_agent_; | 65 scoped_ptr<net::HttpUserAgentSettings> http_user_agent_settings_; |
| 67 | 66 |
| 68 DISALLOW_COPY_AND_ASSIGN(RequestContext); | 67 DISALLOW_COPY_AND_ASSIGN(RequestContext); |
| 69 }; | 68 }; |
| 70 | 69 |
| 71 // Lazy-getter for RequestContext objects. | 70 // Lazy-getter for RequestContext objects. |
| 72 class RequestContextGetter : public net::URLRequestContextGetter { | 71 class RequestContextGetter : public net::URLRequestContextGetter { |
| 73 public: | 72 public: |
| 74 RequestContextGetter( | 73 RequestContextGetter( |
| 75 net::URLRequestContextGetter* baseline_context_getter, | 74 net::URLRequestContextGetter* baseline_context_getter, |
| 76 const std::string& user_agent); | 75 const std::string& user_agent); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 | 221 |
| 223 const scoped_refptr<HttpBridge::RequestContextGetter> | 222 const scoped_refptr<HttpBridge::RequestContextGetter> |
| 224 request_context_getter_; | 223 request_context_getter_; |
| 225 | 224 |
| 226 DISALLOW_COPY_AND_ASSIGN(HttpBridgeFactory); | 225 DISALLOW_COPY_AND_ASSIGN(HttpBridgeFactory); |
| 227 }; | 226 }; |
| 228 | 227 |
| 229 } // namespace syncer | 228 } // namespace syncer |
| 230 | 229 |
| 231 #endif // SYNC_INTERNAL_API_PUBLIC_HTTP_BRIDGE_H_ | 230 #endif // SYNC_INTERNAL_API_PUBLIC_HTTP_BRIDGE_H_ |
| OLD | NEW |