Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(676)

Side by Side Diff: chrome/browser/sync/glue/http_bridge.cc

Issue 8375039: Create a content::UrlFetcher interface that lives in content/public/common and convert users to i... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: review comments Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 212
213 void HttpBridge::MakeAsynchronousPost() { 213 void HttpBridge::MakeAsynchronousPost() {
214 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 214 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
215 base::AutoLock lock(fetch_state_lock_); 215 base::AutoLock lock(fetch_state_lock_);
216 DCHECK(!fetch_state_.request_completed); 216 DCHECK(!fetch_state_.request_completed);
217 if (fetch_state_.aborted) 217 if (fetch_state_.aborted)
218 return; 218 return;
219 219
220 fetch_state_.url_poster = URLFetcher::Create(0, url_for_request_, 220 fetch_state_.url_poster = URLFetcher::Create(0, url_for_request_,
221 URLFetcher::POST, this); 221 URLFetcher::POST, this);
222 fetch_state_.url_poster->set_request_context(context_getter_for_request_); 222 fetch_state_.url_poster->SetRequestContext(context_getter_for_request_);
223 fetch_state_.url_poster->set_upload_data(content_type_, request_content_); 223 fetch_state_.url_poster->SetUploadData(content_type_, request_content_);
224 fetch_state_.url_poster->set_extra_request_headers(extra_headers_); 224 fetch_state_.url_poster->SetExtraRequestHeaders(extra_headers_);
225 fetch_state_.url_poster->set_load_flags(net::LOAD_DO_NOT_SEND_COOKIES); 225 fetch_state_.url_poster->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES);
226 fetch_state_.url_poster->Start(); 226 fetch_state_.url_poster->Start();
227 } 227 }
228 228
229 int HttpBridge::GetResponseContentLength() const { 229 int HttpBridge::GetResponseContentLength() const {
230 DCHECK_EQ(MessageLoop::current(), created_on_loop_); 230 DCHECK_EQ(MessageLoop::current(), created_on_loop_);
231 base::AutoLock lock(fetch_state_lock_); 231 base::AutoLock lock(fetch_state_lock_);
232 DCHECK(fetch_state_.request_completed); 232 DCHECK(fetch_state_.request_completed);
233 return fetch_state_.response_content.size(); 233 return fetch_state_.response_content.size();
234 } 234 }
235 235
(...skipping 23 matching lines...) Expand all
259 return; 259 return;
260 260
261 fetch_state_.aborted = true; 261 fetch_state_.aborted = true;
262 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, 262 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE,
263 fetch_state_.url_poster); 263 fetch_state_.url_poster);
264 fetch_state_.url_poster = NULL; 264 fetch_state_.url_poster = NULL;
265 fetch_state_.error_code = net::ERR_ABORTED; 265 fetch_state_.error_code = net::ERR_ABORTED;
266 http_post_completed_.Signal(); 266 http_post_completed_.Signal();
267 } 267 }
268 268
269 void HttpBridge::OnURLFetchComplete(const URLFetcher *source) { 269 void HttpBridge::OnURLFetchComplete(const content::URLFetcher *source) {
270 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 270 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
271 base::AutoLock lock(fetch_state_lock_); 271 base::AutoLock lock(fetch_state_lock_);
272 if (fetch_state_.aborted) 272 if (fetch_state_.aborted)
273 return; 273 return;
274 274
275 fetch_state_.request_completed = true; 275 fetch_state_.request_completed = true;
276 fetch_state_.request_succeeded = 276 fetch_state_.request_succeeded =
277 (net::URLRequestStatus::SUCCESS == source->status().status()); 277 (net::URLRequestStatus::SUCCESS == source->GetStatus().status());
278 fetch_state_.http_response_code = source->response_code(); 278 fetch_state_.http_response_code = source->GetResponseCode();
279 fetch_state_.error_code = source->status().error(); 279 fetch_state_.error_code = source->GetStatus().error();
280 280
281 source->GetResponseAsString(&fetch_state_.response_content); 281 source->GetResponseAsString(&fetch_state_.response_content);
282 fetch_state_.response_headers = source->response_headers(); 282 fetch_state_.response_headers = source->GetResponseHeaders();
283 283
284 // End of the line for url_poster_. It lives only on the IO loop. 284 // End of the line for url_poster_. It lives only on the IO loop.
285 // We defer deletion because we're inside a callback from a component of the 285 // We defer deletion because we're inside a callback from a component of the
286 // URLFetcher, so it seems most natural / "polite" to let the stack unwind. 286 // URLFetcher, so it seems most natural / "polite" to let the stack unwind.
287 MessageLoop::current()->DeleteSoon(FROM_HERE, fetch_state_.url_poster); 287 MessageLoop::current()->DeleteSoon(FROM_HERE, fetch_state_.url_poster);
288 fetch_state_.url_poster = NULL; 288 fetch_state_.url_poster = NULL;
289 289
290 // Wake the blocked syncer thread in MakeSynchronousPost. 290 // Wake the blocked syncer thread in MakeSynchronousPost.
291 // WARNING: DONT DO ANYTHING AFTER THIS CALL! |this| may be deleted! 291 // WARNING: DONT DO ANYTHING AFTER THIS CALL! |this| may be deleted!
292 http_post_completed_.Signal(); 292 http_post_completed_.Signal();
293 } 293 }
294 294
295 } // namespace browser_sync 295 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/http_bridge.h ('k') | chrome/browser/sync/glue/http_bridge_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698