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