| 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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1306 } | 1312 } |
| 1307 | 1313 |
| 1308 void DownloadItemImpl::StartDownload() { | 1314 void DownloadItemImpl::StartDownload() { |
| 1309 BrowserThread::PostTask( | 1315 BrowserThread::PostTask( |
| 1310 BrowserThread::FILE, FROM_HERE, | 1316 BrowserThread::FILE, FROM_HERE, |
| 1311 base::Bind(&DownloadFile::Initialize, | 1317 base::Bind(&DownloadFile::Initialize, |
| 1312 // Safe because we control download file lifetime. | 1318 // Safe because we control download file lifetime. |
| 1313 base::Unretained(download_file_.get()), | 1319 base::Unretained(download_file_.get()), |
| 1314 base::Bind(&DownloadItemImpl::OnDownloadFileInitialized, | 1320 base::Bind(&DownloadItemImpl::OnDownloadFileInitialized, |
| 1315 weak_ptr_factory_.GetWeakPtr()), | 1321 weak_ptr_factory_.GetWeakPtr()), |
| 1322 base::Bind(&DownloadItemImpl::CancelRequestWithOffset, |
| 1323 weak_ptr_factory_.GetWeakPtr()), |
| 1316 received_slices_)); | 1324 received_slices_)); |
| 1317 } | 1325 } |
| 1318 | 1326 |
| 1319 void DownloadItemImpl::OnDownloadFileInitialized( | 1327 void DownloadItemImpl::OnDownloadFileInitialized( |
| 1320 DownloadInterruptReason result) { | 1328 DownloadInterruptReason result) { |
| 1321 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1329 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1322 DCHECK(state_ == TARGET_PENDING_INTERNAL || | 1330 DCHECK(state_ == TARGET_PENDING_INTERNAL || |
| 1323 state_ == INTERRUPTED_TARGET_PENDING_INTERNAL) | 1331 state_ == INTERRUPTED_TARGET_PENDING_INTERNAL) |
| 1324 << "Unexpected state: " << DebugDownloadStateString(state_); | 1332 << "Unexpected state: " << DebugDownloadStateString(state_); |
| 1325 | 1333 |
| (...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2264 case RESUME_MODE_USER_CONTINUE: | 2272 case RESUME_MODE_USER_CONTINUE: |
| 2265 return "USER_CONTINUE"; | 2273 return "USER_CONTINUE"; |
| 2266 case RESUME_MODE_USER_RESTART: | 2274 case RESUME_MODE_USER_RESTART: |
| 2267 return "USER_RESTART"; | 2275 return "USER_RESTART"; |
| 2268 } | 2276 } |
| 2269 NOTREACHED() << "Unknown resume mode " << mode; | 2277 NOTREACHED() << "Unknown resume mode " << mode; |
| 2270 return "unknown"; | 2278 return "unknown"; |
| 2271 } | 2279 } |
| 2272 | 2280 |
| 2273 } // namespace content | 2281 } // namespace content |
| OLD | NEW |