| 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 // File method ordering: Methods in this file are in the same order as | 5 // File method ordering: Methods in this file are in the same order as |
| 6 // in download_item_impl.h, with the following exception: The public | 6 // in download_item_impl.h, with the following exception: The public |
| 7 // interface Start is placed in chronological order with the other | 7 // interface Start is placed in chronological order with the other |
| 8 // (private) routines that together define a DownloadItem's state | 8 // (private) routines that together define a DownloadItem's state |
| 9 // transitions as the download progresses. See "Download progression | 9 // transitions as the download progresses. See "Download progression |
| 10 // cascade" later in this file. | 10 // cascade" later in this file. |
| (...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1054 content_disposition_ = new_create_info.content_disposition; | 1054 content_disposition_ = new_create_info.content_disposition; |
| 1055 // It is possible that the previous download attempt failed right before the | 1055 // It is possible that the previous download attempt failed right before the |
| 1056 // response is received. Need to reset the MIME type. | 1056 // response is received. Need to reset the MIME type. |
| 1057 mime_type_ = new_create_info.mime_type; | 1057 mime_type_ = new_create_info.mime_type; |
| 1058 | 1058 |
| 1059 // Don't update observers. This method is expected to be called just before a | 1059 // Don't update observers. This method is expected to be called just before a |
| 1060 // DownloadFile is created and Start() is called. The observers will be | 1060 // DownloadFile is created and Start() is called. The observers will be |
| 1061 // notified when the download transitions to the IN_PROGRESS state. | 1061 // notified when the download transitions to the IN_PROGRESS state. |
| 1062 } | 1062 } |
| 1063 | 1063 |
| 1064 void DownloadItemImpl::CancelRequestWithOffset(int64_t offset) { |
| 1065 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1066 if (job_) |
| 1067 job_->CancelRequestWithOffset(offset); |
| 1068 } |
| 1069 |
| 1064 void DownloadItemImpl::NotifyRemoved() { | 1070 void DownloadItemImpl::NotifyRemoved() { |
| 1065 for (auto& observer : observers_) | 1071 for (auto& observer : observers_) |
| 1066 observer.OnDownloadRemoved(this); | 1072 observer.OnDownloadRemoved(this); |
| 1067 } | 1073 } |
| 1068 | 1074 |
| 1069 void DownloadItemImpl::OnDownloadedFileRemoved() { | 1075 void DownloadItemImpl::OnDownloadedFileRemoved() { |
| 1070 file_externally_removed_ = true; | 1076 file_externally_removed_ = true; |
| 1071 DVLOG(20) << __func__ << "() download=" << DebugString(true); | 1077 DVLOG(20) << __func__ << "() download=" << DebugString(true); |
| 1072 UpdateObservers(); | 1078 UpdateObservers(); |
| 1073 } | 1079 } |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1296 } | 1302 } |
| 1297 | 1303 |
| 1298 void DownloadItemImpl::StartDownload() { | 1304 void DownloadItemImpl::StartDownload() { |
| 1299 BrowserThread::PostTask( | 1305 BrowserThread::PostTask( |
| 1300 BrowserThread::FILE, FROM_HERE, | 1306 BrowserThread::FILE, FROM_HERE, |
| 1301 base::Bind(&DownloadFile::Initialize, | 1307 base::Bind(&DownloadFile::Initialize, |
| 1302 // Safe because we control download file lifetime. | 1308 // Safe because we control download file lifetime. |
| 1303 base::Unretained(download_file_.get()), | 1309 base::Unretained(download_file_.get()), |
| 1304 base::Bind(&DownloadItemImpl::OnDownloadFileInitialized, | 1310 base::Bind(&DownloadItemImpl::OnDownloadFileInitialized, |
| 1305 weak_ptr_factory_.GetWeakPtr()), | 1311 weak_ptr_factory_.GetWeakPtr()), |
| 1312 base::Bind(&DownloadItemImpl::CancelRequestWithOffset, |
| 1313 weak_ptr_factory_.GetWeakPtr()), |
| 1306 received_slices_)); | 1314 received_slices_)); |
| 1307 } | 1315 } |
| 1308 | 1316 |
| 1309 void DownloadItemImpl::OnDownloadFileInitialized( | 1317 void DownloadItemImpl::OnDownloadFileInitialized( |
| 1310 DownloadInterruptReason result) { | 1318 DownloadInterruptReason result) { |
| 1311 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1319 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1312 DCHECK(state_ == TARGET_PENDING_INTERNAL || | 1320 DCHECK(state_ == TARGET_PENDING_INTERNAL || |
| 1313 state_ == INTERRUPTED_TARGET_PENDING_INTERNAL) | 1321 state_ == INTERRUPTED_TARGET_PENDING_INTERNAL) |
| 1314 << "Unexpected state: " << DebugDownloadStateString(state_); | 1322 << "Unexpected state: " << DebugDownloadStateString(state_); |
| 1315 | 1323 |
| (...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2254 case RESUME_MODE_USER_CONTINUE: | 2262 case RESUME_MODE_USER_CONTINUE: |
| 2255 return "USER_CONTINUE"; | 2263 return "USER_CONTINUE"; |
| 2256 case RESUME_MODE_USER_RESTART: | 2264 case RESUME_MODE_USER_RESTART: |
| 2257 return "USER_RESTART"; | 2265 return "USER_RESTART"; |
| 2258 } | 2266 } |
| 2259 NOTREACHED() << "Unknown resume mode " << mode; | 2267 NOTREACHED() << "Unknown resume mode " << mode; |
| 2260 return "unknown"; | 2268 return "unknown"; |
| 2261 } | 2269 } |
| 2262 | 2270 |
| 2263 } // namespace content | 2271 } // namespace content |
| OLD | NEW |