summaryrefslogtreecommitdiffstats
path: root/chrome/browser/download/download_process_handle.cc
blob: f4c7f321ddda56d2205eceee447831c98efcbbde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// 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 "chrome/browser/profiles/profile.h"
#include "chrome/browser/tab_contents/tab_util.h"
#include "content/browser/browser_thread.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) {
}

TabContents* DownloadProcessHandle::GetTabContents() {
  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();
}