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

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

Issue 6932046: Added DownloadProcessHandle class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup per Pawel's 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
Index: chrome/browser/download/download_manager.cc
diff --git a/chrome/browser/download/download_manager.cc b/chrome/browser/download/download_manager.cc
index f7e05f7d20dd12d9141808959a504543c157f7a7..ec8926edda9d1b1f6d23089374ac54e293b92c1f 100644
--- a/chrome/browser/download/download_manager.cc
+++ b/chrome/browser/download/download_manager.cc
@@ -21,6 +21,7 @@
#include "chrome/browser/download/download_history.h"
#include "chrome/browser/download/download_item.h"
#include "chrome/browser/download/download_prefs.h"
+#include "chrome/browser/download/download_process_handle.h"
#include "chrome/browser/download/download_safe_browsing_client.h"
#include "chrome/browser/download/download_status_updater.h"
#include "chrome/browser/download/download_util.h"
@@ -432,8 +433,7 @@ void DownloadManager::OnPathExistenceAvailable(DownloadCreateInfo* info) {
if (!select_file_dialog_.get())
select_file_dialog_ = SelectFileDialog::Create(this);
- TabContents* contents = tab_util::GetTabContentsByID(info->child_id,
- info->render_view_id);
+ TabContents* contents = info->process_handle.GetTabContents();
SelectFileDialog::FileTypeInfo file_type_info;
FilePath::StringType extension = info->suggested_path.Extension();
if (!extension.empty()) {
@@ -703,22 +703,15 @@ void DownloadManager::DownloadCancelled(int32 download_id) {
download_history_->UpdateEntry(download);
}
- DownloadCancelledInternal(download_id,
- download->render_process_id(),
- download->request_id());
+ DownloadCancelledInternal(download_id, download->process_handle());
}
-void DownloadManager::DownloadCancelledInternal(int download_id,
- int render_process_id,
- int request_id) {
+void DownloadManager::DownloadCancelledInternal(
+ int download_id, DownloadProcessHandle process_handle) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
// Cancel the network request. RDH is guaranteed to outlive the IO thread.
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- NewRunnableFunction(&download_util::CancelDownloadRequest,
- g_browser_process->resource_dispatcher_host(),
- render_process_id,
- request_id));
+ download_util::CancelDownloadRequest(
+ g_browser_process->resource_dispatcher_host(), process_handle);
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
@@ -776,8 +769,7 @@ void DownloadManager::PauseDownload(int32 download_id, bool pause) {
NewRunnableMethod(this,
&DownloadManager::PauseDownloadRequest,
g_browser_process->resource_dispatcher_host(),
- download->render_process_id(),
- download->request_id(),
+ download->process_handle(),
pause));
}
@@ -787,11 +779,12 @@ void DownloadManager::UpdateAppIcon() {
}
void DownloadManager::PauseDownloadRequest(ResourceDispatcherHost* rdh,
- int render_process_id,
- int request_id,
+ DownloadProcessHandle process_handle,
bool pause) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- rdh->PauseRequest(render_process_id, request_id, pause);
+ rdh->PauseRequest(process_handle.child_id(),
+ process_handle.request_id(),
+ pause);
}
void DownloadManager::RemoveDownload(int64 download_handle) {
@@ -982,9 +975,7 @@ void DownloadManager::FileSelectionCanceled(void* params) {
// The user didn't pick a place to save the file, so need to cancel the
// download that's already in progress to the temporary location.
DownloadCreateInfo* info = reinterpret_cast<DownloadCreateInfo*>(params);
- DownloadCancelledInternal(info->download_id,
- info->child_id,
- info->request_id);
+ DownloadCancelledInternal(info->download_id, info->process_handle);
}
void DownloadManager::DangerousDownloadValidated(DownloadItem* download) {
@@ -1044,7 +1035,7 @@ void DownloadManager::OnCreateDownloadEntryComplete(
// Show in the appropriate browser UI.
// This includes buttons to save or cancel, for a dangerous download.
- ShowDownloadInBrowser(info, download);
+ ShowDownloadInBrowser(info.process_handle, download);
// Inform interested objects about the new download.
NotifyModelChanged();
@@ -1068,13 +1059,12 @@ void DownloadManager::OnCreateDownloadEntryComplete(
}
}
-void DownloadManager::ShowDownloadInBrowser(const DownloadCreateInfo& info,
- DownloadItem* download) {
+void DownloadManager::ShowDownloadInBrowser(
+ DownloadProcessHandle process_handle, DownloadItem* download) {
// The 'contents' may no longer exist if the user closed the tab before we
// get this start completion event. If it does, tell the origin TabContents
// to display its download shelf.
- TabContents* contents = tab_util::GetTabContentsByID(info.child_id,
- info.render_view_id);
+ TabContents* contents = process_handle.GetTabContents();
// If the contents no longer exists, we start the download in the last active
// browser. This is not ideal but better than fully hiding the download from

Powered by Google App Engine
This is Rietveld 408576698