| 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 stream_reader_->RegisterCallback(base::Closure()); | 125 stream_reader_->RegisterCallback(base::Closure()); |
| 126 | 126 |
| 127 new_path.clear(); | 127 new_path.clear(); |
| 128 } | 128 } |
| 129 | 129 |
| 130 BrowserThread::PostTask( | 130 BrowserThread::PostTask( |
| 131 BrowserThread::UI, FROM_HERE, | 131 BrowserThread::UI, FROM_HERE, |
| 132 base::Bind(callback, reason, new_path)); | 132 base::Bind(callback, reason, new_path)); |
| 133 } | 133 } |
| 134 | 134 |
| 135 void DownloadFileImpl::Detach(base::Closure callback) { | 135 void DownloadFileImpl::Detach(const DetachCompletionCallback& callback) { |
| 136 // Doing the annotation here leaves a small window during | 136 // Doing the annotation here leaves a small window during |
| 137 // which the file has the final name but hasn't been marked with the | 137 // which the file has the final name but hasn't been marked with the |
| 138 // Mark Of The Web. However, it allows anti-virus scanners on Windows | 138 // Mark Of The Web. However, it allows anti-virus scanners on Windows |
| 139 // to actually see the data (http://crbug.com/127999), and the Window | 139 // to actually see the data (http://crbug.com/127999), and the Window |
| 140 // is pretty small (round trip to the UI thread). | 140 // is pretty small (round trip to the UI thread). |
| 141 AnnotateWithSourceInformation(); | 141 DownloadInterruptReason interrupt_reason = |
| 142 | 142 file_.AnnotateWithSourceInformation(); |
| 143 file_.Detach(); | 143 file_.Detach(); |
| 144 | 144 |
| 145 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback); | 145 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 146 base::Bind(callback, interrupt_reason)); |
| 146 } | 147 } |
| 147 | 148 |
| 148 void DownloadFileImpl::Cancel() { | 149 void DownloadFileImpl::Cancel() { |
| 149 file_.Cancel(); | 150 file_.Cancel(); |
| 150 } | 151 } |
| 151 | 152 |
| 152 void DownloadFileImpl::AnnotateWithSourceInformation() { | |
| 153 bound_net_log_.BeginEvent(net::NetLog::TYPE_DOWNLOAD_FILE_ANNOTATED); | |
| 154 file_.AnnotateWithSourceInformation(); | |
| 155 bound_net_log_.EndEvent(net::NetLog::TYPE_DOWNLOAD_FILE_ANNOTATED); | |
| 156 } | |
| 157 | |
| 158 FilePath DownloadFileImpl::FullPath() const { | 153 FilePath DownloadFileImpl::FullPath() const { |
| 159 return file_.full_path(); | 154 return file_.full_path(); |
| 160 } | 155 } |
| 161 | 156 |
| 162 bool DownloadFileImpl::InProgress() const { | 157 bool DownloadFileImpl::InProgress() const { |
| 163 return file_.in_progress(); | 158 return file_.in_progress(); |
| 164 } | 159 } |
| 165 | 160 |
| 166 int64 DownloadFileImpl::BytesSoFar() const { | 161 int64 DownloadFileImpl::BytesSoFar() const { |
| 167 return file_.bytes_so_far(); | 162 return file_.bytes_so_far(); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 base::Bind(&DownloadDestinationObserver::DestinationUpdate, | 280 base::Bind(&DownloadDestinationObserver::DestinationUpdate, |
| 286 observer_, BytesSoFar(), CurrentSpeed(), GetHashState())); | 281 observer_, BytesSoFar(), CurrentSpeed(), GetHashState())); |
| 287 } | 282 } |
| 288 | 283 |
| 289 // static | 284 // static |
| 290 int DownloadFile::GetNumberOfDownloadFiles() { | 285 int DownloadFile::GetNumberOfDownloadFiles() { |
| 291 return number_active_objects_; | 286 return number_active_objects_; |
| 292 } | 287 } |
| 293 | 288 |
| 294 } // namespace content | 289 } // namespace content |
| OLD | NEW |