| 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_file.h" | |
| 6 | |
| 7 #include <string> | |
| 8 | |
| 9 #include "base/file_util.h" | |
| 10 #include "base/stringprintf.h" | |
| 11 #include "chrome/browser/download/download_create_info.h" | |
| 12 #include "chrome/browser/download/download_manager.h" | |
| 13 #include "chrome/browser/download/download_util.h" | |
| 14 #include "content/browser/browser_thread.h" | |
| 15 | |
| 16 DownloadFile::DownloadFile(const DownloadCreateInfo* info, | |
| 17 DownloadManager* download_manager) | |
| 18 : BaseFile(info->save_info.file_path, | |
| 19 info->url(), | |
| 20 info->referrer_url, | |
| 21 info->received_bytes, | |
| 22 info->save_info.file_stream), | |
| 23 id_(info->download_id), | |
| 24 request_handle_(info->request_handle), | |
| 25 download_manager_(download_manager) { | |
| 26 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | |
| 27 } | |
| 28 | |
| 29 DownloadFile::~DownloadFile() { | |
| 30 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | |
| 31 } | |
| 32 | |
| 33 void DownloadFile::CancelDownloadRequest() { | |
| 34 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | |
| 35 request_handle_.CancelRequest(); | |
| 36 } | |
| 37 | |
| 38 DownloadManager* DownloadFile::GetDownloadManager() { | |
| 39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | |
| 40 return download_manager_.get(); | |
| 41 } | |
| 42 | |
| 43 std::string DownloadFile::DebugString() const { | |
| 44 return base::StringPrintf("{" | |
| 45 " id_ = " "%d" | |
| 46 " request_handle = %s" | |
| 47 " Base File = %s" | |
| 48 " }", | |
| 49 id_, | |
| 50 request_handle_.DebugString().c_str(), | |
| 51 BaseFile::DebugString().c_str()); | |
| 52 } | |
| OLD | NEW |