| 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 const Pickle& hash_state) |
| 20 : file_(info->save_info.file_path, | 21 : file_(info->save_info.file_path, |
| 21 info->url(), | 22 info->url(), |
| 22 info->referrer_url, | 23 info->referrer_url, |
| 23 info->received_bytes, | 24 info->received_bytes, |
| 25 hash_state, |
| 24 info->save_info.file_stream), | 26 info->save_info.file_stream), |
| 25 id_(info->download_id), | 27 id_(info->download_id), |
| 26 request_handle_(request_handle), | 28 request_handle_(request_handle), |
| 27 download_manager_(download_manager) { | 29 download_manager_(download_manager) { |
| 28 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 30 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 29 } | 31 } |
| 30 | 32 |
| 31 DownloadFileImpl::~DownloadFileImpl() { | 33 DownloadFileImpl::~DownloadFileImpl() { |
| 32 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 34 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 33 } | 35 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 } | 73 } |
| 72 | 74 |
| 73 int64 DownloadFileImpl::BytesSoFar() const { | 75 int64 DownloadFileImpl::BytesSoFar() const { |
| 74 return file_.bytes_so_far(); | 76 return file_.bytes_so_far(); |
| 75 } | 77 } |
| 76 | 78 |
| 77 bool DownloadFileImpl::GetSha256Hash(std::string* hash) { | 79 bool DownloadFileImpl::GetSha256Hash(std::string* hash) { |
| 78 return file_.GetSha256Hash(hash); | 80 return file_.GetSha256Hash(hash); |
| 79 } | 81 } |
| 80 | 82 |
| 83 bool DownloadFileImpl::GetSha256HashState(Pickle* hash_state) { |
| 84 return file_.GetSha256HashState(hash_state); |
| 85 } |
| 86 |
| 87 bool DownloadFileImpl::SetSha256HashState(Pickle* hash_state) { |
| 88 return file_.SetSha256HashState(hash_state); |
| 89 } |
| 90 |
| 81 // DownloadFileInterface implementation. | 91 // DownloadFileInterface implementation. |
| 82 void DownloadFileImpl::CancelDownloadRequest() { | 92 void DownloadFileImpl::CancelDownloadRequest() { |
| 83 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 93 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 84 request_handle_->CancelRequest(); | 94 request_handle_->CancelRequest(); |
| 85 } | 95 } |
| 86 | 96 |
| 87 int DownloadFileImpl::Id() const { | 97 int DownloadFileImpl::Id() const { |
| 88 return id_.local(); | 98 return id_.local(); |
| 89 } | 99 } |
| 90 | 100 |
| 91 DownloadManager* DownloadFileImpl::GetDownloadManager() { | 101 DownloadManager* DownloadFileImpl::GetDownloadManager() { |
| 92 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 102 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 93 return download_manager_.get(); | 103 return download_manager_.get(); |
| 94 } | 104 } |
| 95 | 105 |
| 96 const DownloadId& DownloadFileImpl::GlobalId() const { | 106 const DownloadId& DownloadFileImpl::GlobalId() const { |
| 97 return id_; | 107 return id_; |
| 98 } | 108 } |
| 99 | 109 |
| 100 std::string DownloadFileImpl::DebugString() const { | 110 std::string DownloadFileImpl::DebugString() const { |
| 101 return base::StringPrintf("{" | 111 return base::StringPrintf("{" |
| 102 " id_ = " "%d" | 112 " id_ = " "%d" |
| 103 " request_handle = %s" | 113 " request_handle = %s" |
| 104 " Base File = %s" | 114 " Base File = %s" |
| 105 " }", | 115 " }", |
| 106 id_.local(), | 116 id_.local(), |
| 107 request_handle_->DebugString().c_str(), | 117 request_handle_->DebugString().c_str(), |
| 108 file_.DebugString().c_str()); | 118 file_.DebugString().c_str()); |
| 109 } | 119 } |
| OLD | NEW |