| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/download/download_file_impl.h" | 5 #include "content/browser/download/download_file_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "content/browser/download/download_create_info.h" | 10 #include "content/browser/download/download_create_info.h" |
| 11 #include "content/browser/download/download_manager.h" | 11 #include "content/browser/download/download_manager.h" |
| 12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
| 13 | 13 |
| 14 using content::BrowserThread; | 14 using content::BrowserThread; |
| 15 | 15 |
| 16 DownloadFileImpl::DownloadFileImpl( | 16 DownloadFileImpl::DownloadFileImpl( |
| 17 const DownloadCreateInfo* info, | 17 const DownloadCreateInfo* info, |
| 18 DownloadRequestHandleInterface* request_handle, | 18 DownloadRequestHandleInterface* request_handle, |
| 19 DownloadManager* download_manager) | 19 DownloadManager* download_manager) |
| 20 : file_(info->save_info.file_path, | 20 : file_(info->save_info.file_path, |
| 21 info->url(), | 21 info->url(), |
| 22 info->referrer_url, | 22 info->referrer_url, |
| 23 info->received_bytes, | 23 info->received_bytes, |
| 24 info->save_info.hash_state, |
| 24 info->save_info.file_stream), | 25 info->save_info.file_stream), |
| 25 id_(info->download_id), | 26 id_(info->download_id), |
| 26 request_handle_(request_handle), | 27 request_handle_(request_handle), |
| 27 download_manager_(download_manager) { | 28 download_manager_(download_manager) { |
| 28 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 29 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 29 } | 30 } |
| 30 | 31 |
| 31 DownloadFileImpl::~DownloadFileImpl() { | 32 DownloadFileImpl::~DownloadFileImpl() { |
| 32 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 33 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 33 } | 34 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 } | 72 } |
| 72 | 73 |
| 73 int64 DownloadFileImpl::BytesSoFar() const { | 74 int64 DownloadFileImpl::BytesSoFar() const { |
| 74 return file_.bytes_so_far(); | 75 return file_.bytes_so_far(); |
| 75 } | 76 } |
| 76 | 77 |
| 77 bool DownloadFileImpl::GetSha256Hash(std::string* hash) { | 78 bool DownloadFileImpl::GetSha256Hash(std::string* hash) { |
| 78 return file_.GetSha256Hash(hash); | 79 return file_.GetSha256Hash(hash); |
| 79 } | 80 } |
| 80 | 81 |
| 82 std::string DownloadFileImpl::GetSha256HashState() { |
| 83 return file_.GetSha256HashState(); |
| 84 } |
| 85 |
| 86 bool DownloadFileImpl::SetSha256HashState(const std::string& hash_state) { |
| 87 return file_.SetSha256HashState(hash_state); |
| 88 } |
| 89 |
| 81 // DownloadFileInterface implementation. | 90 // DownloadFileInterface implementation. |
| 82 void DownloadFileImpl::CancelDownloadRequest() { | 91 void DownloadFileImpl::CancelDownloadRequest() { |
| 83 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 92 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 84 request_handle_->CancelRequest(); | 93 request_handle_->CancelRequest(); |
| 85 } | 94 } |
| 86 | 95 |
| 87 int DownloadFileImpl::Id() const { | 96 int DownloadFileImpl::Id() const { |
| 88 return id_.local(); | 97 return id_.local(); |
| 89 } | 98 } |
| 90 | 99 |
| 91 DownloadManager* DownloadFileImpl::GetDownloadManager() { | 100 DownloadManager* DownloadFileImpl::GetDownloadManager() { |
| 92 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 101 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 93 return download_manager_.get(); | 102 return download_manager_.get(); |
| 94 } | 103 } |
| 95 | 104 |
| 96 const DownloadId& DownloadFileImpl::GlobalId() const { | 105 const DownloadId& DownloadFileImpl::GlobalId() const { |
| 97 return id_; | 106 return id_; |
| 98 } | 107 } |
| 99 | 108 |
| 100 std::string DownloadFileImpl::DebugString() const { | 109 std::string DownloadFileImpl::DebugString() const { |
| 101 return base::StringPrintf("{" | 110 return base::StringPrintf("{" |
| 102 " id_ = " "%d" | 111 " id_ = " "%d" |
| 103 " request_handle = %s" | 112 " request_handle = %s" |
| 104 " Base File = %s" | 113 " Base File = %s" |
| 105 " }", | 114 " }", |
| 106 id_.local(), | 115 id_.local(), |
| 107 request_handle_->DebugString().c_str(), | 116 request_handle_->DebugString().c_str(), |
| 108 file_.DebugString().c_str()); | 117 file_.DebugString().c_str()); |
| 109 } | 118 } |
| OLD | NEW |