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

Unified Diff: content/browser/download/download_resource_handler.cc

Issue 2476163003: Refactor ResourceHandler API. (Closed)
Patch Set: Minor cleanups, one real fix Created 4 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/download/download_resource_handler.cc
diff --git a/content/browser/download/download_resource_handler.cc b/content/browser/download/download_resource_handler.cc
index a0acc44e3ba78627e536e8aec1d0d887d43fdae1..1b7ec843446200547b1317cc825130ccfed0ba5b 100644
--- a/content/browser/download/download_resource_handler.cc
+++ b/content/browser/download/download_resource_handler.cc
@@ -139,25 +139,29 @@ std::unique_ptr<ResourceHandler> DownloadResourceHandler::Create(
return handler;
}
-bool DownloadResourceHandler::OnRequestRedirected(
+void DownloadResourceHandler::OnRequestRedirected(
const net::RedirectInfo& redirect_info,
ResourceResponse* response,
- bool* defer) {
- return core_.OnRequestRedirected();
+ bool* defer_or_cancel) {
+ if (!core_.OnRequestRedirected()) {
+ *defer_or_cancel = true;
+ controller()->Cancel();
+ }
}
// Send the download creation information to the download thread.
-bool DownloadResourceHandler::OnResponseStarted(
- ResourceResponse* response,
- bool* defer) {
+void DownloadResourceHandler::OnResponseStarted(ResourceResponse* response,
+ bool* defer_or_cancel) {
// The MIME type in ResourceResponse is the product of
// MimeTypeResourceHandler.
- return core_.OnResponseStarted(response->head.mime_type);
+ if (!core_.OnResponseStarted(response->head.mime_type)) {
+ *defer_or_cancel = true;
+ controller()->Cancel();
+ }
}
-bool DownloadResourceHandler::OnWillStart(const GURL& url, bool* defer) {
- return true;
-}
+void DownloadResourceHandler::OnWillStart(const GURL& url,
+ bool* defer_or_cancel) {}
// Create a new buffer, which will be handed to the download thread for file
// writing and deletion.
@@ -168,8 +172,12 @@ bool DownloadResourceHandler::OnWillRead(scoped_refptr<net::IOBuffer>* buf,
}
// Pass the buffer to the download file writer.
-bool DownloadResourceHandler::OnReadCompleted(int bytes_read, bool* defer) {
- return core_.OnReadCompleted(bytes_read, defer);
+void DownloadResourceHandler::OnReadCompleted(int bytes_read,
+ bool* defer_or_cancel) {
+ if (!core_.OnReadCompleted(bytes_read, defer_or_cancel)) {
+ *defer_or_cancel = true;
+ controller()->Cancel();
+ }
}
void DownloadResourceHandler::OnResponseCompleted(
« no previous file with comments | « content/browser/download/download_resource_handler.h ('k') | content/browser/download/save_file_resource_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698