blob: 6bf41c7e0486f2f7a58350c5eb590f5b4756d48b [file] [log] [blame]
[email protected]6c69796d2010-07-16 21:41:161// Copyright (c) 2010 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
[email protected]cdaa8652008-09-13 02:48:595#include "chrome/browser/download/download_file.h"
initial.commit09911bf2008-07-26 23:55:296
7#include "base/file_util.h"
[email protected]0940dde2010-07-21 18:26:458#include "chrome/browser/chrome_thread.h"
[email protected]b47da722009-02-23 23:54:189#include "chrome/browser/download/download_manager.h"
[email protected]290c9702010-03-09 04:01:3610#include "chrome/browser/download/download_util.h"
[email protected]a0835ac2010-09-13 19:40:0811#include "chrome/browser/history/download_create_info.h"
[email protected]e1acf6f2008-10-27 20:43:3312
[email protected]326a6a92010-09-10 20:21:1313DownloadFile::DownloadFile(const DownloadCreateInfo* info,
14 DownloadManager* download_manager)
[email protected]f15edeb2010-08-27 16:27:1515 : BaseFile(info->save_info.file_path,
16 info->url,
17 info->referrer_url,
[email protected]326a6a92010-09-10 20:21:1318 info->received_bytes,
[email protected]f15edeb2010-08-27 16:27:1519 info->save_info.file_stream),
initial.commit09911bf2008-07-26 23:55:2920 id_(info->download_id),
[email protected]76543b92009-08-31 17:27:4521 child_id_(info->child_id),
[email protected]326a6a92010-09-10 20:21:1322 request_id_(info->request_id),
23 download_manager_(download_manager) {
[email protected]0940dde2010-07-21 18:26:4524 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE));
[email protected]326a6a92010-09-10 20:21:1325
initial.commit09911bf2008-07-26 23:55:2926}
27
28DownloadFile::~DownloadFile() {
[email protected]0940dde2010-07-21 18:26:4529 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE));
initial.commit09911bf2008-07-26 23:55:2930}
31
[email protected]594cd7d2010-07-21 03:23:5632void DownloadFile::DeleteCrDownload() {
[email protected]f15edeb2010-08-27 16:27:1533 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE));
[email protected]594cd7d2010-07-21 03:23:5634 FilePath crdownload = download_util::GetCrDownloadPath(full_path_);
35 file_util::Delete(crdownload, false);
36}
37
[email protected]0940dde2010-07-21 18:26:4538void DownloadFile::CancelDownloadRequest(ResourceDispatcherHost* rdh) {
39 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE));
40 ChromeThread::PostTask(
41 ChromeThread::IO, FROM_HERE,
42 NewRunnableFunction(&download_util::CancelDownloadRequest,
43 rdh,
44 child_id_,
45 request_id_));
46}
[email protected]326a6a92010-09-10 20:21:1347
[email protected]326a6a92010-09-10 20:21:1348DownloadManager* DownloadFile::GetDownloadManager() {
49 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE));
50 return download_manager_.get();
51}