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

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

Issue 8416018: Replace NewRunnableMethod with Callback in DownloadFileManager. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: lint errors 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/download/download_file_manager.cc
===================================================================
--- content/browser/download/download_file_manager.cc (revision 107442)
+++ content/browser/download/download_file_manager.cc (working copy)
@@ -4,10 +4,13 @@
#include "content/browser/download/download_file_manager.h"
+#include <set>
+#include <string>
Randy Smith (Not in Mondays) 2011/10/28 17:42:31 Why the extra includes?
achuithb 2011/10/28 19:37:37 To satisfy gcl lint (include what you use). We are
+
+#include "base/bind.h"
#include "base/file_util.h"
#include "base/logging.h"
#include "base/stl_util.h"
-#include "base/task.h"
#include "base/utf_string_conversions.h"
#include "content/browser/browser_thread.h"
#include "content/browser/download/download_buffer.h"
@@ -41,7 +44,7 @@
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
- NewRunnableMethod(this, &DownloadFileManager::OnShutdown));
+ base::Bind(&DownloadFileManager::OnShutdown, this));
}
void DownloadFileManager::OnShutdown() {
@@ -78,8 +81,8 @@
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(download_manager,
- &DownloadManager::StartDownload, info->download_id));
+ base::Bind(&DownloadManager::StartDownload, download_manager,
+ info->download_id));
}
DownloadFile* DownloadFileManager::GetDownloadFile(DownloadId global_id) {
@@ -110,8 +113,8 @@
DownloadManager* manager = download_file->GetDownloadManager();
if (manager) {
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(manager, &DownloadManager::UpdateDownload,
- global_id.local(), download_file->bytes_so_far()));
+ base::Bind(&DownloadManager::UpdateDownload, manager,
+ global_id.local(), download_file->bytes_so_far()));
}
}
}
@@ -135,9 +138,9 @@
bool hash_needed = manager->delegate()->GenerateFileHash();
BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
- NewRunnableMethod(this, &DownloadFileManager::CreateDownloadFile,
- info, request_handle, make_scoped_refptr(manager),
- hash_needed));
+ base::Bind(&DownloadFileManager::CreateDownloadFile, this,
+ info, request_handle, make_scoped_refptr(manager),
+ hash_needed));
}
// We don't forward an update to the UI thread here, since we want to throttle
@@ -172,16 +175,11 @@
if (download_manager) {
BrowserThread::PostTask(
- BrowserThread::UI,
- FROM_HERE,
- NewRunnableMethod(
- download_manager,
- &DownloadManager::OnDownloadInterrupted,
- global_id.local(),
- bytes_downloaded,
- ConvertNetErrorToInterruptReason(
- write_result,
- DOWNLOAD_INTERRUPT_FROM_DISK)));
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&DownloadManager::OnDownloadInterrupted,
+ download_manager, global_id.local(), bytes_downloaded,
+ ConvertNetErrorToInterruptReason(
+ write_result, DOWNLOAD_INTERRUPT_FROM_DISK)));
}
}
}
@@ -215,24 +213,16 @@
if (reason == DOWNLOAD_INTERRUPT_REASON_NONE) {
BrowserThread::PostTask(
- BrowserThread::UI,
- FROM_HERE,
- NewRunnableMethod(
- download_manager,
- &DownloadManager::OnResponseCompleted,
- global_id.local(),
- download_file->bytes_so_far(),
- hash));
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&DownloadManager::OnResponseCompleted,
+ download_manager, global_id.local(),
+ download_file->bytes_so_far(), hash));
} else {
BrowserThread::PostTask(
- BrowserThread::UI,
- FROM_HERE,
- NewRunnableMethod(
- download_manager,
- &DownloadManager::OnDownloadInterrupted,
- global_id.local(),
- download_file->bytes_so_far(),
- reason));
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&DownloadManager::OnDownloadInterrupted,
+ download_manager, global_id.local(),
+ download_file->bytes_so_far(), reason));
}
// We need to keep the download around until the UI thread has finalized
// the name.
@@ -383,9 +373,8 @@
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(
- download_manager, &DownloadManager::OnDownloadRenamedToFinalName,
- global_id.local(), new_path, uniquifier));
+ base::Bind(&DownloadManager::OnDownloadRenamedToFinalName,
+ download_manager, global_id.local(), new_path, uniquifier));
}
// Called only from RenameInProgressDownloadFile and
@@ -409,13 +398,11 @@
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(download_manager,
- &DownloadManager::OnDownloadInterrupted,
- global_id.local(),
- download_file->bytes_so_far(),
- ConvertNetErrorToInterruptReason(
- rename_error,
- DOWNLOAD_INTERRUPT_FROM_DISK)));
+ base::Bind(&DownloadManager::OnDownloadInterrupted,
+ download_manager, global_id.local(),
+ download_file->bytes_so_far(),
+ ConvertNetErrorToInterruptReason(
+ rename_error, DOWNLOAD_INTERRUPT_FROM_DISK)));
}
void DownloadFileManager::EraseDownload(DownloadId global_id) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698