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

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

Issue 114193009: [Download] Return DownloadInterruptReason from OnStartedCallback (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 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 9f00ef660b53a4a43cecf1eb89f6eabde3e3cb71..28efa068aa01f0c2495885dbc37439ebee6dd1a4 100644
--- a/content/browser/download/download_resource_handler.cc
+++ b/content/browser/download/download_resource_handler.cc
@@ -37,12 +37,12 @@ namespace {
void CallStartedCBOnUIThread(
const DownloadUrlParameters::OnStartedCallback& started_cb,
DownloadItem* item,
- net::Error error) {
+ DownloadInterruptReason interrupt_reason) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (started_cb.is_null())
return;
- started_cb.Run(item, error);
+ started_cb.Run(item, interrupt_reason);
}
// Static function in order to prevent any accidental accesses to
@@ -58,7 +58,7 @@ static void StartOnUIThread(
// NULL in unittests or if the page closed right after starting the
// download.
if (!started_cb.is_null())
- started_cb.Run(NULL, net::ERR_ACCESS_DENIED);
+ started_cb.Run(NULL, DOWNLOAD_INTERRUPT_REASON_USER_CANCELED);
return;
}
@@ -206,13 +206,16 @@ bool DownloadResourceHandler::OnResponseStarted(
}
void DownloadResourceHandler::CallStartedCB(
- DownloadItem* item, net::Error error) {
+ DownloadItem* item,
+ DownloadInterruptReason interrupt_reason) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
if (started_cb_.is_null())
return;
BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- base::Bind(&CallStartedCBOnUIThread, started_cb_, item, error));
+ BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(
+ &CallStartedCBOnUIThread, started_cb_, item, interrupt_reason));
started_cb_.Reset();
}
@@ -378,7 +381,7 @@ void DownloadResourceHandler::OnResponseCompleted(
RecordNetworkBlockage(base::TimeTicks::Now() - download_start_time_,
total_pause_time_);
- CallStartedCB(NULL, error_code);
+ CallStartedCB(NULL, reason);
// Send the info down the stream. Conditional is in case we get
// OnResponseCompleted without OnResponseStarted.
@@ -463,7 +466,7 @@ DownloadResourceHandler::~DownloadResourceHandler() {
// This won't do anything if the callback was called before.
// If it goes through, it will likely be because OnWillStart() returned
// false somewhere in the chain of resource handlers.
- CallStartedCB(NULL, net::ERR_ACCESS_DENIED);
+ CallStartedCB(NULL, DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED);
// Remove output stream callback if a stream exists.
if (stream_writer_)
« no previous file with comments | « content/browser/download/download_resource_handler.h ('k') | content/browser/download/drag_download_file.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698