Index: chrome/browser/download/download_file_manager.cc |
diff --git a/chrome/browser/download/download_file_manager.cc b/chrome/browser/download/download_file_manager.cc |
index 2522a9804c7ea7b1a737e287a4be5f0582b7871b..7d0b0e74c52ae8b67365f2b64d4f5feef2244723 100644 |
--- a/chrome/browser/download/download_file_manager.cc |
+++ b/chrome/browser/download/download_file_manager.cc |
@@ -11,6 +11,7 @@ |
#include "base/utf_string_conversions.h" |
#include "build/build_config.h" |
#include "chrome/browser/download/download_manager.h" |
+#include "chrome/browser/download/download_process_handle.h" |
#include "chrome/browser/download/download_util.h" |
#include "chrome/browser/history/download_create_info.h" |
#include "chrome/browser/net/chrome_url_request_context.h" |
@@ -30,21 +31,6 @@ namespace { |
// cause it to become unresponsive (in milliseconds). |
const int kUpdatePeriodMs = 500; |
-DownloadManager* DownloadManagerForRenderViewHost(int render_process_id, |
- int render_view_id) { |
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
- |
- TabContents* contents = tab_util::GetTabContentsByID(render_process_id, |
- render_view_id); |
- if (contents) { |
- Profile* profile = contents->profile(); |
- if (profile) |
- return profile->GetDownloadManager(); |
- } |
- |
- return NULL; |
-} |
- |
} // namespace |
DownloadFileManager::DownloadFileManager(ResourceDispatcherHost* rdh) |
@@ -70,6 +56,7 @@ void DownloadFileManager::OnShutdown() { |
} |
void DownloadFileManager::CreateDownloadFile(DownloadCreateInfo* info, |
+ DownloadProcessHandle process, |
DownloadManager* download_manager, |
bool get_hash) { |
VLOG(20) << __FUNCTION__ << "()" << " info = " << info->DebugString(); |
@@ -78,13 +65,7 @@ void DownloadFileManager::CreateDownloadFile(DownloadCreateInfo* info, |
scoped_ptr<DownloadFile> |
download_file(new DownloadFile(info, download_manager)); |
if (!download_file->Initialize(get_hash)) { |
- BrowserThread::PostTask( |
- BrowserThread::IO, FROM_HERE, |
- NewRunnableFunction(&download_util::CancelDownloadRequest, |
- resource_dispatcher_host_, |
- info->child_id, |
- info->request_id)); |
- delete info; |
+ process.CancelDownload(resource_dispatcher_host_); |
return; |
} |
@@ -97,7 +78,7 @@ void DownloadFileManager::CreateDownloadFile(DownloadCreateInfo* info, |
BrowserThread::PostTask( |
BrowserThread::IO, FROM_HERE, |
NewRunnableMethod(this, &DownloadFileManager::ResumeDownloadRequest, |
- info->child_id, info->request_id)); |
+ process)); |
StartUpdateTimer(); |
@@ -107,11 +88,14 @@ void DownloadFileManager::CreateDownloadFile(DownloadCreateInfo* info, |
&DownloadManager::StartDownload, info)); |
} |
-void DownloadFileManager::ResumeDownloadRequest(int child_id, int request_id) { |
+void DownloadFileManager::ResumeDownloadRequest( |
+ DownloadProcessHandle process) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
// This balances the pause in DownloadResourceHandler::OnResponseStarted. |
- resource_dispatcher_host_->PauseRequest(child_id, request_id, false); |
+ resource_dispatcher_host_->PauseRequest(process.child_id(), |
+ process.request_id(), |
+ false); |
} |
DownloadFile* DownloadFileManager::GetDownloadFile(int id) { |
@@ -158,15 +142,9 @@ void DownloadFileManager::StartDownload(DownloadCreateInfo* info) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
DCHECK(info); |
- DownloadManager* manager = DownloadManagerForRenderViewHost( |
- info->child_id, info->render_view_id); |
+ DownloadManager* manager = info->process_handle.GetDownloadManager(); |
if (!manager) { |
- BrowserThread::PostTask( |
- BrowserThread::IO, FROM_HERE, |
- NewRunnableFunction(&download_util::CancelDownloadRequest, |
- resource_dispatcher_host_, |
- info->child_id, |
- info->request_id)); |
+ info->process_handle.CancelDownload(resource_dispatcher_host_); |
delete info; |
return; |
} |
@@ -178,7 +156,8 @@ void DownloadFileManager::StartDownload(DownloadCreateInfo* info) { |
BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
NewRunnableMethod(this, &DownloadFileManager::CreateDownloadFile, |
- info, make_scoped_refptr(manager), hash_needed)); |
+ info, info->process_handle, |
+ make_scoped_refptr(manager), hash_needed)); |
} |
// We don't forward an update to the UI thread here, since we want to throttle |