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

Side by Side Diff: content/browser/loader/buffered_resource_handler.cc

Issue 23496076: WIP - Refactor programmatic downloads Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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) 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 "content/browser/loader/buffered_resource_handler.h" 5 #include "content/browser/loader/buffered_resource_handler.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 *defer = true; 337 *defer = true;
338 return true; 338 return true;
339 } 339 }
340 if (has_plugin) 340 if (has_plugin)
341 return true; 341 return true;
342 #endif 342 #endif
343 } 343 }
344 344
345 // Install download handler 345 // Install download handler
346 info->set_is_download(true); 346 info->set_is_download(true);
347 scoped_ptr<ResourceHandler> handler( 347 scoped_ptr<ResourceHandler> handler(host_->CreateResourceHandlerForDownload(
348 host_->CreateResourceHandlerForDownload( 348 request_,
349 request_, 349 must_download));
350 true, // is_content_initiated
351 must_download,
352 content::DownloadItem::kInvalidId,
353 scoped_ptr<DownloadSaveInfo>(new DownloadSaveInfo()),
354 DownloadUrlParameters::OnStartedCallback()));
355 return UseAlternateNextHandler(handler.Pass()); 350 return UseAlternateNextHandler(handler.Pass());
356 } 351 }
357 352
358 bool BufferedResourceHandler::UseAlternateNextHandler( 353 bool BufferedResourceHandler::UseAlternateNextHandler(
359 scoped_ptr<ResourceHandler> new_handler) { 354 scoped_ptr<ResourceHandler> new_handler) {
360 if (response_->head.headers.get() && // Can be NULL if FTP. 355 if (response_->head.headers.get() && // Can be NULL if FTP.
361 response_->head.headers->response_code() / 100 != 2) { 356 response_->head.headers->response_code() / 100 != 2) {
362 // The response code indicates that this is an error page, but we don't 357 // The response code indicates that this is an error page, but we don't
363 // know how to display the content. We follow Firefox here and show our 358 // know how to display the content. We follow Firefox here and show our
364 // own error page instead of triggering a download. 359 // own error page instead of triggering a download.
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 const std::vector<WebPluginInfo>& plugins) { 459 const std::vector<WebPluginInfo>& plugins) {
465 bool defer = false; 460 bool defer = false;
466 if (!ProcessResponse(&defer)) { 461 if (!ProcessResponse(&defer)) {
467 controller()->Cancel(); 462 controller()->Cancel();
468 } else if (!defer) { 463 } else if (!defer) {
469 controller()->Resume(); 464 controller()->Resume();
470 } 465 }
471 } 466 }
472 467
473 } // namespace content 468 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_internals_ui.cc ('k') | content/browser/loader/resource_dispatcher_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698