Chromium Code Reviews| Index: chrome/browser/download/download_process_handle.cc |
| diff --git a/chrome/browser/download/download_process_handle.cc b/chrome/browser/download/download_process_handle.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2c7983a4de801ba64ec11e9c4ef1e44baa3191e0 |
| --- /dev/null |
| +++ b/chrome/browser/download/download_process_handle.cc |
| @@ -0,0 +1,55 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/download/download_process_handle.h" |
| + |
| +#include <string> |
| + |
| +#include "base/file_util.h" |
| +#include "base/stringprintf.h" |
| +#include "chrome/browser/download/download_manager.h" |
| +#include "chrome/browser/download/download_util.h" |
| +#include "chrome/browser/profiles/profile.h" |
| +#include "chrome/browser/tab_contents/tab_util.h" |
| +#include "content/browser/browser_thread.h" |
| +#include "content/browser/renderer_host/resource_dispatcher_host.h" |
| +#include "content/browser/tab_contents/tab_contents.h" |
| + |
| +DownloadProcessHandle::DownloadProcessHandle() |
| + : child_id_(-1), render_view_id_(-1), request_id_(-1) { |
| +} |
| + |
| +DownloadProcessHandle::DownloadProcessHandle(int child_id, |
| + int render_view_id, |
| + int request_id) |
| + : child_id_(child_id), |
| + render_view_id_(render_view_id), |
| + request_id_(request_id) { |
| +} |
| + |
| +void DownloadProcessHandle::CancelDownload(ResourceDispatcherHost* rdh) { |
|
Paweł Hajdan Jr.
2011/05/05 20:13:51
I'm still not convinced about having this method h
ahendrickson
2011/05/06 16:16:50
Done.
|
| + BrowserThread::PostTask( |
| + BrowserThread::IO, FROM_HERE, |
| + NewRunnableFunction(&download_util::CancelDownloadRequest, |
| + rdh, |
| + child_id_, |
| + request_id_)); |
| +} |
| + |
| +TabContents* DownloadProcessHandle::GetTabContents() { |
|
Paweł Hajdan Jr.
2011/05/05 20:13:51
Please add a comment to the declaration that those
ahendrickson
2011/05/06 16:16:50
OK, but I assumed the DCHECK was comment enough.
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| + return tab_util::GetTabContentsByID(child_id_, render_view_id_); |
| +} |
| + |
| +DownloadManager* DownloadProcessHandle::GetDownloadManager() { |
| + TabContents* contents = GetTabContents(); |
| + if (!contents) |
| + return NULL; |
| + |
| + Profile* profile = contents->profile(); |
| + if (!profile) |
| + return NULL; |
| + |
| + return profile->GetDownloadManager(); |
| +} |