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

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

Issue 6932046: Added DownloadProcessHandle class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added comments. Created 9 years, 7 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 | « chrome/browser/download/download_file_manager.h ('k') | chrome/browser/download/download_file_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..faa85ba1ae4e44a53e8c5b0130f422631a68a945 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)
@@ -78,12 +64,8 @@ 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));
+ download_util::CancelDownloadRequest(resource_dispatcher_host_,
+ info->process_handle);
delete info;
return;
}
@@ -97,7 +79,7 @@ void DownloadFileManager::CreateDownloadFile(DownloadCreateInfo* info,
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
NewRunnableMethod(this, &DownloadFileManager::ResumeDownloadRequest,
- info->child_id, info->request_id));
+ info->process_handle));
StartUpdateTimer();
@@ -107,11 +89,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 +143,10 @@ 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));
+ download_util::CancelDownloadRequest(resource_dispatcher_host_,
+ info->process_handle);
delete info;
return;
}
@@ -178,7 +158,8 @@ void DownloadFileManager::StartDownload(DownloadCreateInfo* info) {
BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
NewRunnableMethod(this, &DownloadFileManager::CreateDownloadFile,
- info, make_scoped_refptr(manager), hash_needed));
+ info,
+ make_scoped_refptr(manager), hash_needed));
}
// We don't forward an update to the UI thread here, since we want to throttle
« no previous file with comments | « chrome/browser/download/download_file_manager.h ('k') | chrome/browser/download/download_file_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698