| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 rename_error, | 122 rename_error, |
| 123 content::DOWNLOAD_INTERRUPT_FROM_DISK); | 123 content::DOWNLOAD_INTERRUPT_FROM_DISK); |
| 124 new_path.clear(); | 124 new_path.clear(); |
| 125 } | 125 } |
| 126 | 126 |
| 127 BrowserThread::PostTask( | 127 BrowserThread::PostTask( |
| 128 BrowserThread::UI, FROM_HERE, | 128 BrowserThread::UI, FROM_HERE, |
| 129 base::Bind(callback, reason, new_path)); | 129 base::Bind(callback, reason, new_path)); |
| 130 } | 130 } |
| 131 | 131 |
| 132 void DownloadFileImpl::Detach(base::Closure callback) { | 132 void DownloadFileImpl::Detach(const DetachCompletionCallback& callback) { |
| 133 // Doing the annotation here leaves a small window during | 133 // Doing the annotation here leaves a small window during |
| 134 // which the file has the final name but hasn't been marked with the | 134 // which the file has the final name but hasn't been marked with the |
| 135 // Mark Of The Web. However, it allows anti-virus scanners on Windows | 135 // Mark Of The Web. However, it allows anti-virus scanners on Windows |
| 136 // to actually see the data (http://crbug.com/127999), and the Window | 136 // to actually see the data (http://crbug.com/127999), and the Window |
| 137 // is pretty small (round trip to the UI thread). | 137 // is pretty small (round trip to the UI thread). |
| 138 AnnotateWithSourceInformation(); | 138 net::Error annotate_result = file_.AnnotateWithSourceInformation(); |
| 139 content::DownloadInterruptReason interrupt_reason = |
| 140 content::ConvertNetErrorToInterruptReason( |
| 141 annotate_result, |
| 142 content::DOWNLOAD_INTERRUPT_FROM_DISK); |
| 139 | 143 |
| 140 file_.Detach(); | 144 file_.Detach(); |
| 141 | 145 |
| 142 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback); | 146 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 147 base::Bind(callback, interrupt_reason)); |
| 143 } | 148 } |
| 144 | 149 |
| 145 void DownloadFileImpl::Cancel() { | 150 void DownloadFileImpl::Cancel() { |
| 146 file_.Cancel(); | 151 file_.Cancel(); |
| 147 } | 152 } |
| 148 | 153 |
| 149 void DownloadFileImpl::AnnotateWithSourceInformation() { | |
| 150 bound_net_log_.BeginEvent(net::NetLog::TYPE_DOWNLOAD_FILE_ANNOTATED); | |
| 151 file_.AnnotateWithSourceInformation(); | |
| 152 bound_net_log_.EndEvent(net::NetLog::TYPE_DOWNLOAD_FILE_ANNOTATED); | |
| 153 } | |
| 154 | |
| 155 FilePath DownloadFileImpl::FullPath() const { | 154 FilePath DownloadFileImpl::FullPath() const { |
| 156 return file_.full_path(); | 155 return file_.full_path(); |
| 157 } | 156 } |
| 158 | 157 |
| 159 bool DownloadFileImpl::InProgress() const { | 158 bool DownloadFileImpl::InProgress() const { |
| 160 return file_.in_progress(); | 159 return file_.in_progress(); |
| 161 } | 160 } |
| 162 | 161 |
| 163 int64 DownloadFileImpl::BytesSoFar() const { | 162 int64 DownloadFileImpl::BytesSoFar() const { |
| 164 return file_.bytes_so_far(); | 163 return file_.bytes_so_far(); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 } | 306 } |
| 308 } | 307 } |
| 309 | 308 |
| 310 void DownloadFileImpl::SendUpdate() { | 309 void DownloadFileImpl::SendUpdate() { |
| 311 BrowserThread::PostTask( | 310 BrowserThread::PostTask( |
| 312 BrowserThread::UI, FROM_HERE, | 311 BrowserThread::UI, FROM_HERE, |
| 313 base::Bind(&DownloadManager::UpdateDownload, | 312 base::Bind(&DownloadManager::UpdateDownload, |
| 314 download_manager_, id_.local(), | 313 download_manager_, id_.local(), |
| 315 BytesSoFar(), CurrentSpeed(), GetHashState())); | 314 BytesSoFar(), CurrentSpeed(), GetHashState())); |
| 316 } | 315 } |
| OLD | NEW |