OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/download/download_process_handle.h" | |
6 | |
7 #include <string> | |
8 | |
9 #include "base/file_util.h" | |
10 #include "base/stringprintf.h" | |
11 #include "chrome/browser/download/download_manager.h" | |
12 #include "chrome/browser/download/download_util.h" | |
13 #include "chrome/browser/profiles/profile.h" | |
14 #include "chrome/browser/tab_contents/tab_util.h" | |
15 #include "content/browser/browser_thread.h" | |
16 #include "content/browser/renderer_host/resource_dispatcher_host.h" | |
17 #include "content/browser/tab_contents/tab_contents.h" | |
18 | |
19 DownloadProcessHandle::DownloadProcessHandle() | |
20 : child_id_(-1), render_view_id_(-1), request_id_(-1) { | |
21 } | |
22 | |
23 DownloadProcessHandle::DownloadProcessHandle(int child_id, | |
24 int render_view_id, | |
25 int request_id) | |
26 : child_id_(child_id), | |
27 render_view_id_(render_view_id), | |
28 request_id_(request_id) { | |
29 } | |
30 | |
31 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.
| |
32 BrowserThread::PostTask( | |
33 BrowserThread::IO, FROM_HERE, | |
34 NewRunnableFunction(&download_util::CancelDownloadRequest, | |
35 rdh, | |
36 child_id_, | |
37 request_id_)); | |
38 } | |
39 | |
40 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.
| |
41 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
42 return tab_util::GetTabContentsByID(child_id_, render_view_id_); | |
43 } | |
44 | |
45 DownloadManager* DownloadProcessHandle::GetDownloadManager() { | |
46 TabContents* contents = GetTabContents(); | |
47 if (!contents) | |
48 return NULL; | |
49 | |
50 Profile* profile = contents->profile(); | |
51 if (!profile) | |
52 return NULL; | |
53 | |
54 return profile->GetDownloadManager(); | |
55 } | |
OLD | NEW |