OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser/browser_thread.h" | 10 #include "content/browser/browser_thread.h" |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 DCHECK(!content_type_.empty()) << "Payload not set"; | 191 DCHECK(!content_type_.empty()) << "Payload not set"; |
192 | 192 |
193 if (!BrowserThread::PostTask( | 193 if (!BrowserThread::PostTask( |
194 BrowserThread::IO, FROM_HERE, | 194 BrowserThread::IO, FROM_HERE, |
195 NewRunnableMethod(this, &HttpBridge::CallMakeAsynchronousPost))) { | 195 NewRunnableMethod(this, &HttpBridge::CallMakeAsynchronousPost))) { |
196 // This usually happens when we're in a unit test. | 196 // This usually happens when we're in a unit test. |
197 LOG(WARNING) << "Could not post CallMakeAsynchronousPost task"; | 197 LOG(WARNING) << "Could not post CallMakeAsynchronousPost task"; |
198 return false; | 198 return false; |
199 } | 199 } |
200 | 200 |
201 if (!http_post_completed_.Wait()) // Block until network request completes | 201 // Block until network request completes or is aborted. See |
202 NOTREACHED(); // or is aborted. See OnURLFetchComplete | 202 // OnURLFetchComplete and Abort. |
203 // and Abort. | 203 http_post_completed_.Wait(); |
204 | 204 |
205 base::AutoLock lock(fetch_state_lock_); | 205 base::AutoLock lock(fetch_state_lock_); |
206 DCHECK(fetch_state_.request_completed || fetch_state_.aborted); | 206 DCHECK(fetch_state_.request_completed || fetch_state_.aborted); |
207 *error_code = fetch_state_.error_code; | 207 *error_code = fetch_state_.error_code; |
208 *response_code = fetch_state_.http_response_code; | 208 *response_code = fetch_state_.http_response_code; |
209 return fetch_state_.request_succeeded; | 209 return fetch_state_.request_succeeded; |
210 } | 210 } |
211 | 211 |
212 void HttpBridge::MakeAsynchronousPost() { | 212 void HttpBridge::MakeAsynchronousPost() { |
213 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 213 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 // URLFetcher, so it seems most natural / "polite" to let the stack unwind. | 290 // URLFetcher, so it seems most natural / "polite" to let the stack unwind. |
291 MessageLoop::current()->DeleteSoon(FROM_HERE, fetch_state_.url_poster); | 291 MessageLoop::current()->DeleteSoon(FROM_HERE, fetch_state_.url_poster); |
292 fetch_state_.url_poster = NULL; | 292 fetch_state_.url_poster = NULL; |
293 | 293 |
294 // Wake the blocked syncer thread in MakeSynchronousPost. | 294 // Wake the blocked syncer thread in MakeSynchronousPost. |
295 // WARNING: DONT DO ANYTHING AFTER THIS CALL! |this| may be deleted! | 295 // WARNING: DONT DO ANYTHING AFTER THIS CALL! |this| may be deleted! |
296 http_post_completed_.Signal(); | 296 http_post_completed_.Signal(); |
297 } | 297 } |
298 | 298 |
299 } // namespace browser_sync | 299 } // namespace browser_sync |
OLD | NEW |