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

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: Removed code extraneous to this CL. Created 9 years, 8 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..f7de9375d4ad278d7ee4f7a205f94fdd9c2db87b 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()) {
@@ -713,12 +713,9 @@ void DownloadManager::DownloadCancelledInternal(int download_id,
int request_id) {
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));
+ DownloadProcessHandle process_handle(-1, render_process_id, request_id);
+ process_handle.CancelDownload(
+ g_browser_process->resource_dispatcher_host());
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
@@ -983,8 +980,8 @@ void DownloadManager::FileSelectionCanceled(void* params) {
// 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);
+ info->process_handle.child_id(),
+ info->process_handle.child_id());
}
void DownloadManager::DangerousDownloadValidated(DownloadItem* download) {
@@ -1044,7 +1041,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 +1065,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