OLD | NEW |
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 80 |
81 // Lazy-getter for RequestContext objects. | 81 // Lazy-getter for RequestContext objects. |
82 class SYNC_EXPORT_PRIVATE RequestContextGetter | 82 class SYNC_EXPORT_PRIVATE RequestContextGetter |
83 : public net::URLRequestContextGetter { | 83 : public net::URLRequestContextGetter { |
84 public: | 84 public: |
85 RequestContextGetter( | 85 RequestContextGetter( |
86 net::URLRequestContextGetter* baseline_context_getter, | 86 net::URLRequestContextGetter* baseline_context_getter, |
87 const std::string& user_agent); | 87 const std::string& user_agent); |
88 | 88 |
89 // net::URLRequestContextGetter implementation. | 89 // net::URLRequestContextGetter implementation. |
90 virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE; | 90 virtual net::URLRequestContext* GetURLRequestContext() override; |
91 virtual scoped_refptr<base::SingleThreadTaskRunner> | 91 virtual scoped_refptr<base::SingleThreadTaskRunner> |
92 GetNetworkTaskRunner() const OVERRIDE; | 92 GetNetworkTaskRunner() const override; |
93 | 93 |
94 protected: | 94 protected: |
95 virtual ~RequestContextGetter(); | 95 virtual ~RequestContextGetter(); |
96 | 96 |
97 private: | 97 private: |
98 scoped_refptr<net::URLRequestContextGetter> baseline_context_getter_; | 98 scoped_refptr<net::URLRequestContextGetter> baseline_context_getter_; |
99 const scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; | 99 const scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; |
100 // User agent to apply to the net::URLRequestContext. | 100 // User agent to apply to the net::URLRequestContext. |
101 const std::string user_agent_; | 101 const std::string user_agent_; |
102 | 102 |
103 // Lazily initialized by GetURLRequestContext(). | 103 // Lazily initialized by GetURLRequestContext(). |
104 scoped_ptr<RequestContext> context_; | 104 scoped_ptr<RequestContext> context_; |
105 | 105 |
106 DISALLOW_COPY_AND_ASSIGN(RequestContextGetter); | 106 DISALLOW_COPY_AND_ASSIGN(RequestContextGetter); |
107 }; | 107 }; |
108 | 108 |
109 HttpBridge(RequestContextGetter* context, | 109 HttpBridge(RequestContextGetter* context, |
110 const NetworkTimeUpdateCallback& network_time_update_callback); | 110 const NetworkTimeUpdateCallback& network_time_update_callback); |
111 | 111 |
112 // HttpPostProvider implementation. | 112 // HttpPostProvider implementation. |
113 virtual void SetExtraRequestHeaders(const char* headers) OVERRIDE; | 113 virtual void SetExtraRequestHeaders(const char* headers) override; |
114 virtual void SetURL(const char* url, int port) OVERRIDE; | 114 virtual void SetURL(const char* url, int port) override; |
115 virtual void SetPostPayload(const char* content_type, int content_length, | 115 virtual void SetPostPayload(const char* content_type, int content_length, |
116 const char* content) OVERRIDE; | 116 const char* content) override; |
117 virtual bool MakeSynchronousPost(int* error_code, | 117 virtual bool MakeSynchronousPost(int* error_code, |
118 int* response_code) OVERRIDE; | 118 int* response_code) override; |
119 virtual void Abort() OVERRIDE; | 119 virtual void Abort() override; |
120 | 120 |
121 // WARNING: these response content methods are used to extract plain old data | 121 // WARNING: these response content methods are used to extract plain old data |
122 // and not null terminated strings, so you should make sure you have read | 122 // and not null terminated strings, so you should make sure you have read |
123 // GetResponseContentLength() characters when using GetResponseContent. e.g | 123 // GetResponseContentLength() characters when using GetResponseContent. e.g |
124 // string r(b->GetResponseContent(), b->GetResponseContentLength()). | 124 // string r(b->GetResponseContent(), b->GetResponseContentLength()). |
125 virtual int GetResponseContentLength() const OVERRIDE; | 125 virtual int GetResponseContentLength() const override; |
126 virtual const char* GetResponseContent() const OVERRIDE; | 126 virtual const char* GetResponseContent() const override; |
127 virtual const std::string GetResponseHeaderValue( | 127 virtual const std::string GetResponseHeaderValue( |
128 const std::string& name) const OVERRIDE; | 128 const std::string& name) const override; |
129 | 129 |
130 // net::URLFetcherDelegate implementation. | 130 // net::URLFetcherDelegate implementation. |
131 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 131 virtual void OnURLFetchComplete(const net::URLFetcher* source) override; |
132 | 132 |
133 net::URLRequestContextGetter* GetRequestContextGetterForTest() const; | 133 net::URLRequestContextGetter* GetRequestContextGetterForTest() const; |
134 | 134 |
135 protected: | 135 protected: |
136 friend class base::RefCountedThreadSafe<HttpBridge>; | 136 friend class base::RefCountedThreadSafe<HttpBridge>; |
137 | 137 |
138 virtual ~HttpBridge(); | 138 virtual ~HttpBridge(); |
139 | 139 |
140 // Protected virtual so the unit test can override to shunt network requests. | 140 // Protected virtual so the unit test can override to shunt network requests. |
141 virtual void MakeAsynchronousPost(); | 141 virtual void MakeAsynchronousPost(); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 public CancelationObserver { | 228 public CancelationObserver { |
229 public: | 229 public: |
230 HttpBridgeFactory( | 230 HttpBridgeFactory( |
231 const scoped_refptr<net::URLRequestContextGetter>& | 231 const scoped_refptr<net::URLRequestContextGetter>& |
232 baseline_context_getter, | 232 baseline_context_getter, |
233 const NetworkTimeUpdateCallback& network_time_update_callback, | 233 const NetworkTimeUpdateCallback& network_time_update_callback, |
234 CancelationSignal* cancelation_signal); | 234 CancelationSignal* cancelation_signal); |
235 virtual ~HttpBridgeFactory(); | 235 virtual ~HttpBridgeFactory(); |
236 | 236 |
237 // HttpPostProviderFactory: | 237 // HttpPostProviderFactory: |
238 virtual void Init(const std::string& user_agent) OVERRIDE; | 238 virtual void Init(const std::string& user_agent) override; |
239 virtual HttpPostProviderInterface* Create() OVERRIDE; | 239 virtual HttpPostProviderInterface* Create() override; |
240 virtual void Destroy(HttpPostProviderInterface* http) OVERRIDE; | 240 virtual void Destroy(HttpPostProviderInterface* http) override; |
241 | 241 |
242 // CancelationObserver implementation: | 242 // CancelationObserver implementation: |
243 virtual void OnSignalReceived() OVERRIDE; | 243 virtual void OnSignalReceived() override; |
244 | 244 |
245 private: | 245 private: |
246 // Protects |request_context_getter_| and |baseline_request_context_getter_|. | 246 // Protects |request_context_getter_| and |baseline_request_context_getter_|. |
247 base::Lock context_getter_lock_; | 247 base::Lock context_getter_lock_; |
248 | 248 |
249 // This request context is the starting point for the request_context_getter_ | 249 // This request context is the starting point for the request_context_getter_ |
250 // that we eventually use to make requests. During shutdown we must drop all | 250 // that we eventually use to make requests. During shutdown we must drop all |
251 // references to it before the ProfileSyncService's Shutdown() call is | 251 // references to it before the ProfileSyncService's Shutdown() call is |
252 // complete. | 252 // complete. |
253 scoped_refptr<net::URLRequestContextGetter> baseline_request_context_getter_; | 253 scoped_refptr<net::URLRequestContextGetter> baseline_request_context_getter_; |
254 | 254 |
255 // This request context is built on top of the baseline context and shares | 255 // This request context is built on top of the baseline context and shares |
256 // common components. Takes a reference to the | 256 // common components. Takes a reference to the |
257 // baseline_request_context_getter_. It's mostly used on sync thread when | 257 // baseline_request_context_getter_. It's mostly used on sync thread when |
258 // creating connection but is released as soon as possible during shutdown. | 258 // creating connection but is released as soon as possible during shutdown. |
259 // Protected by |context_getter_lock_|. | 259 // Protected by |context_getter_lock_|. |
260 scoped_refptr<HttpBridge::RequestContextGetter> request_context_getter_; | 260 scoped_refptr<HttpBridge::RequestContextGetter> request_context_getter_; |
261 | 261 |
262 NetworkTimeUpdateCallback network_time_update_callback_; | 262 NetworkTimeUpdateCallback network_time_update_callback_; |
263 | 263 |
264 CancelationSignal* const cancelation_signal_; | 264 CancelationSignal* const cancelation_signal_; |
265 | 265 |
266 DISALLOW_COPY_AND_ASSIGN(HttpBridgeFactory); | 266 DISALLOW_COPY_AND_ASSIGN(HttpBridgeFactory); |
267 }; | 267 }; |
268 | 268 |
269 } // namespace syncer | 269 } // namespace syncer |
270 | 270 |
271 #endif // SYNC_INTERNAL_API_PUBLIC_HTTP_BRIDGE_H_ | 271 #endif // SYNC_INTERNAL_API_PUBLIC_HTTP_BRIDGE_H_ |
OLD | NEW |