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

Side by Side Diff: chrome/browser/download/download_process_handle.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, 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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) {
Randy Smith (Not in Mondays) 2011/05/05 20:25:34 I believe it's invalid to call any of the routines
ahendrickson 2011/05/06 16:16:50 In unit tests we call them with -1's; this just ma
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) {
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() {
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698