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 #include "chrome/browser/sync/glue/http_bridge.h" | 5 #include "chrome/browser/sync/glue/http_bridge.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/message_loop_proxy.h" | 8 #include "base/message_loop_proxy.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
11 #include "content/public/common/content_client.h" | 11 #include "content/public/common/content_client.h" |
12 #include "content/public/common/url_fetcher.h" | |
13 #include "net/base/host_resolver.h" | 12 #include "net/base/host_resolver.h" |
14 #include "net/base/load_flags.h" | 13 #include "net/base/load_flags.h" |
15 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
16 #include "net/cookies/cookie_monster.h" | 15 #include "net/cookies/cookie_monster.h" |
17 #include "net/http/http_cache.h" | 16 #include "net/http/http_cache.h" |
18 #include "net/http/http_network_layer.h" | 17 #include "net/http/http_network_layer.h" |
19 #include "net/http/http_response_headers.h" | 18 #include "net/http/http_response_headers.h" |
20 #include "net/proxy/proxy_service.h" | 19 #include "net/proxy/proxy_service.h" |
| 20 #include "net/url_request/url_fetcher.h" |
21 #include "net/url_request/url_request_context.h" | 21 #include "net/url_request/url_request_context.h" |
22 #include "net/url_request/url_request_status.h" | 22 #include "net/url_request/url_request_status.h" |
23 | 23 |
24 using content::BrowserThread; | 24 using content::BrowserThread; |
25 | 25 |
26 namespace browser_sync { | 26 namespace browser_sync { |
27 | 27 |
28 HttpBridge::RequestContextGetter::RequestContextGetter( | 28 HttpBridge::RequestContextGetter::RequestContextGetter( |
29 net::URLRequestContextGetter* baseline_context_getter) | 29 net::URLRequestContextGetter* baseline_context_getter) |
30 : baseline_context_getter_(baseline_context_getter) { | 30 : baseline_context_getter_(baseline_context_getter) { |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 return fetch_state_.request_succeeded; | 214 return fetch_state_.request_succeeded; |
215 } | 215 } |
216 | 216 |
217 void HttpBridge::MakeAsynchronousPost() { | 217 void HttpBridge::MakeAsynchronousPost() { |
218 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 218 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
219 base::AutoLock lock(fetch_state_lock_); | 219 base::AutoLock lock(fetch_state_lock_); |
220 DCHECK(!fetch_state_.request_completed); | 220 DCHECK(!fetch_state_.request_completed); |
221 if (fetch_state_.aborted) | 221 if (fetch_state_.aborted) |
222 return; | 222 return; |
223 | 223 |
224 fetch_state_.url_poster = content::URLFetcher::Create( | 224 fetch_state_.url_poster = net::URLFetcher::Create( |
225 url_for_request_, net::URLFetcher::POST, this); | 225 url_for_request_, net::URLFetcher::POST, this); |
226 fetch_state_.url_poster->SetRequestContext(context_getter_for_request_); | 226 fetch_state_.url_poster->SetRequestContext(context_getter_for_request_); |
227 fetch_state_.url_poster->SetUploadData(content_type_, request_content_); | 227 fetch_state_.url_poster->SetUploadData(content_type_, request_content_); |
228 fetch_state_.url_poster->SetExtraRequestHeaders(extra_headers_); | 228 fetch_state_.url_poster->SetExtraRequestHeaders(extra_headers_); |
229 fetch_state_.url_poster->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES); | 229 fetch_state_.url_poster->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES); |
230 fetch_state_.url_poster->Start(); | 230 fetch_state_.url_poster->Start(); |
231 } | 231 } |
232 | 232 |
233 int HttpBridge::GetResponseContentLength() const { | 233 int HttpBridge::GetResponseContentLength() const { |
234 DCHECK_EQ(MessageLoop::current(), created_on_loop_); | 234 DCHECK_EQ(MessageLoop::current(), created_on_loop_); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 // URLFetcher, so it seems most natural / "polite" to let the stack unwind. | 301 // URLFetcher, so it seems most natural / "polite" to let the stack unwind. |
302 MessageLoop::current()->DeleteSoon(FROM_HERE, fetch_state_.url_poster); | 302 MessageLoop::current()->DeleteSoon(FROM_HERE, fetch_state_.url_poster); |
303 fetch_state_.url_poster = NULL; | 303 fetch_state_.url_poster = NULL; |
304 | 304 |
305 // Wake the blocked syncer thread in MakeSynchronousPost. | 305 // Wake the blocked syncer thread in MakeSynchronousPost. |
306 // WARNING: DONT DO ANYTHING AFTER THIS CALL! |this| may be deleted! | 306 // WARNING: DONT DO ANYTHING AFTER THIS CALL! |this| may be deleted! |
307 http_post_completed_.Signal(); | 307 http_post_completed_.Signal(); |
308 } | 308 } |
309 | 309 |
310 } // namespace browser_sync | 310 } // namespace browser_sync |
OLD | NEW |