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

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

Issue 8373021: Convert URLFetcher::Delegates to use an interface in content/public/common. Also remove the old U... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync and remove unncessary forward declares Created 9 years, 1 month 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"
11 #include "content/common/net/url_fetcher.h"
11 #include "content/public/common/content_client.h" 12 #include "content/public/common/content_client.h"
12 #include "net/base/cookie_monster.h" 13 #include "net/base/cookie_monster.h"
13 #include "net/base/host_resolver.h" 14 #include "net/base/host_resolver.h"
14 #include "net/base/load_flags.h" 15 #include "net/base/load_flags.h"
15 #include "net/base/net_errors.h" 16 #include "net/base/net_errors.h"
16 #include "net/http/http_cache.h" 17 #include "net/http/http_cache.h"
17 #include "net/http/http_network_layer.h" 18 #include "net/http/http_network_layer.h"
18 #include "net/http/http_response_headers.h" 19 #include "net/http/http_response_headers.h"
19 #include "net/proxy/proxy_service.h" 20 #include "net/proxy/proxy_service.h"
20 #include "net/url_request/url_request_context.h" 21 #include "net/url_request/url_request_context.h"
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 return; 259 return;
259 260
260 fetch_state_.aborted = true; 261 fetch_state_.aborted = true;
261 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, 262 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE,
262 fetch_state_.url_poster); 263 fetch_state_.url_poster);
263 fetch_state_.url_poster = NULL; 264 fetch_state_.url_poster = NULL;
264 fetch_state_.error_code = net::ERR_ABORTED; 265 fetch_state_.error_code = net::ERR_ABORTED;
265 http_post_completed_.Signal(); 266 http_post_completed_.Signal();
266 } 267 }
267 268
268 void HttpBridge::OnURLFetchComplete(const URLFetcher *source, 269 void HttpBridge::OnURLFetchComplete(const URLFetcher *source) {
269 const GURL &url,
270 const net::URLRequestStatus &status,
271 int response_code,
272 const net::ResponseCookies &cookies,
273 const std::string &data) {
274 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 270 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
275 base::AutoLock lock(fetch_state_lock_); 271 base::AutoLock lock(fetch_state_lock_);
276 if (fetch_state_.aborted) 272 if (fetch_state_.aborted)
277 return; 273 return;
278 274
279 fetch_state_.request_completed = true; 275 fetch_state_.request_completed = true;
280 fetch_state_.request_succeeded = 276 fetch_state_.request_succeeded =
281 (net::URLRequestStatus::SUCCESS == status.status()); 277 (net::URLRequestStatus::SUCCESS == source->status().status());
282 fetch_state_.http_response_code = response_code; 278 fetch_state_.http_response_code = source->response_code();
283 fetch_state_.error_code = status.error(); 279 fetch_state_.error_code = source->status().error();
284 280
285 fetch_state_.response_content = data; 281 source->GetResponseAsString(&fetch_state_.response_content);
286 fetch_state_.response_headers = source->response_headers(); 282 fetch_state_.response_headers = source->response_headers();
287 283
288 // 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.
289 // 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
290 // 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.
291 MessageLoop::current()->DeleteSoon(FROM_HERE, fetch_state_.url_poster); 287 MessageLoop::current()->DeleteSoon(FROM_HERE, fetch_state_.url_poster);
292 fetch_state_.url_poster = NULL; 288 fetch_state_.url_poster = NULL;
293 289
294 // Wake the blocked syncer thread in MakeSynchronousPost. 290 // Wake the blocked syncer thread in MakeSynchronousPost.
295 // WARNING: DONT DO ANYTHING AFTER THIS CALL! |this| may be deleted! 291 // WARNING: DONT DO ANYTHING AFTER THIS CALL! |this| may be deleted!
296 http_post_completed_.Signal(); 292 http_post_completed_.Signal();
297 } 293 }
298 294
299 } // namespace browser_sync 295 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698