| 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 1255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1266 } | 1266 } |
| 1267 | 1267 |
| 1268 // Successful download start. | 1268 // Successful download start. |
| 1269 DCHECK(download_file_); | 1269 DCHECK(download_file_); |
| 1270 DCHECK(job_); | 1270 DCHECK(job_); |
| 1271 | 1271 |
| 1272 if (state_ == RESUMING_INTERNAL) | 1272 if (state_ == RESUMING_INTERNAL) |
| 1273 UpdateValidatorsOnResumption(new_create_info); | 1273 UpdateValidatorsOnResumption(new_create_info); |
| 1274 | 1274 |
| 1275 if (state_ == INITIAL_INTERNAL && job_->UsesParallelRequests()) | 1275 if (state_ == INITIAL_INTERNAL && job_->UsesParallelRequests()) |
| 1276 RecordDownloadCount(USES_PARALLEL_REQUESTS); | 1276 RecordParallelDownloadCount(PARALLEL_DOWNLOAD_START_COUNT); |
| 1277 | 1277 |
| 1278 TransitionTo(TARGET_PENDING_INTERNAL); | 1278 TransitionTo(TARGET_PENDING_INTERNAL); |
| 1279 | 1279 |
| 1280 job_->Start(); | 1280 job_->Start(); |
| 1281 } | 1281 } |
| 1282 | 1282 |
| 1283 void DownloadItemImpl::StartDownload() { | 1283 void DownloadItemImpl::StartDownload() { |
| 1284 BrowserThread::PostTask( | 1284 BrowserThread::PostTask( |
| 1285 BrowserThread::FILE, FROM_HERE, | 1285 BrowserThread::FILE, FROM_HERE, |
| 1286 base::Bind(&DownloadFile::Initialize, | 1286 base::Bind(&DownloadFile::Initialize, |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1556 | 1556 |
| 1557 void DownloadItemImpl::Completed() { | 1557 void DownloadItemImpl::Completed() { |
| 1558 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1558 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1559 | 1559 |
| 1560 DVLOG(20) << __func__ << "() " << DebugString(false); | 1560 DVLOG(20) << __func__ << "() " << DebugString(false); |
| 1561 | 1561 |
| 1562 DCHECK(all_data_saved_); | 1562 DCHECK(all_data_saved_); |
| 1563 end_time_ = base::Time::Now(); | 1563 end_time_ = base::Time::Now(); |
| 1564 TransitionTo(COMPLETE_INTERNAL); | 1564 TransitionTo(COMPLETE_INTERNAL); |
| 1565 RecordDownloadCompleted(start_tick_, received_bytes_); | 1565 RecordDownloadCompleted(start_tick_, received_bytes_); |
| 1566 if (job_ && job_->UsesParallelRequests()) |
| 1567 RecordParallelDownloadCount(PARALLEL_DOWNLOAD_COMPLETED_COUNT); |
| 1566 | 1568 |
| 1567 if (auto_opened_) { | 1569 if (auto_opened_) { |
| 1568 // If it was already handled by the delegate, do nothing. | 1570 // If it was already handled by the delegate, do nothing. |
| 1569 } else if (GetOpenWhenComplete() || | 1571 } else if (GetOpenWhenComplete() || |
| 1570 ShouldOpenFileBasedOnExtension() || | 1572 ShouldOpenFileBasedOnExtension() || |
| 1571 IsTemporary()) { | 1573 IsTemporary()) { |
| 1572 // If the download is temporary, like in drag-and-drop, do not open it but | 1574 // If the download is temporary, like in drag-and-drop, do not open it but |
| 1573 // we still need to set it auto-opened so that it can be removed from the | 1575 // we still need to set it auto-opened so that it can be removed from the |
| 1574 // download shelf. | 1576 // download shelf. |
| 1575 if (!IsTemporary()) | 1577 if (!IsTemporary()) |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1686 reason == DOWNLOAD_INTERRUPT_REASON_USER_SHUTDOWN) { | 1688 reason == DOWNLOAD_INTERRUPT_REASON_USER_SHUTDOWN) { |
| 1687 if (IsDangerous()) { | 1689 if (IsDangerous()) { |
| 1688 RecordDangerousDownloadDiscard( | 1690 RecordDangerousDownloadDiscard( |
| 1689 reason == DOWNLOAD_INTERRUPT_REASON_USER_CANCELED | 1691 reason == DOWNLOAD_INTERRUPT_REASON_USER_CANCELED |
| 1690 ? DOWNLOAD_DISCARD_DUE_TO_USER_ACTION | 1692 ? DOWNLOAD_DISCARD_DUE_TO_USER_ACTION |
| 1691 : DOWNLOAD_DISCARD_DUE_TO_SHUTDOWN, | 1693 : DOWNLOAD_DISCARD_DUE_TO_SHUTDOWN, |
| 1692 GetDangerType(), GetTargetFilePath()); | 1694 GetDangerType(), GetTargetFilePath()); |
| 1693 } | 1695 } |
| 1694 | 1696 |
| 1695 RecordDownloadCount(CANCELLED_COUNT); | 1697 RecordDownloadCount(CANCELLED_COUNT); |
| 1698 if (job_ && job_->UsesParallelRequests()) |
| 1699 RecordParallelDownloadCount(PARALLEL_DOWNLOAD_CANCELLED_COUNT); |
| 1696 TransitionTo(CANCELLED_INTERNAL); | 1700 TransitionTo(CANCELLED_INTERNAL); |
| 1697 return; | 1701 return; |
| 1698 } | 1702 } |
| 1699 | 1703 |
| 1700 RecordDownloadInterrupted(reason, received_bytes_, total_bytes_); | 1704 RecordDownloadInterrupted(reason, received_bytes_, total_bytes_, |
| 1705 job_ && job_->UsesParallelRequests()); |
| 1701 if (!GetWebContents()) | 1706 if (!GetWebContents()) |
| 1702 RecordDownloadCount(INTERRUPTED_WITHOUT_WEBCONTENTS); | 1707 RecordDownloadCount(INTERRUPTED_WITHOUT_WEBCONTENTS); |
| 1703 | 1708 |
| 1704 TransitionTo(INTERRUPTED_INTERNAL); | 1709 TransitionTo(INTERRUPTED_INTERNAL); |
| 1705 AutoResumeIfValid(); | 1710 AutoResumeIfValid(); |
| 1706 } | 1711 } |
| 1707 | 1712 |
| 1708 void DownloadItemImpl::UpdateProgress( | 1713 void DownloadItemImpl::UpdateProgress( |
| 1709 int64_t bytes_so_far, | 1714 int64_t bytes_so_far, |
| 1710 int64_t bytes_per_sec) { | 1715 int64_t bytes_per_sec) { |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2175 case RESUME_MODE_USER_CONTINUE: | 2180 case RESUME_MODE_USER_CONTINUE: |
| 2176 return "USER_CONTINUE"; | 2181 return "USER_CONTINUE"; |
| 2177 case RESUME_MODE_USER_RESTART: | 2182 case RESUME_MODE_USER_RESTART: |
| 2178 return "USER_RESTART"; | 2183 return "USER_RESTART"; |
| 2179 } | 2184 } |
| 2180 NOTREACHED() << "Unknown resume mode " << mode; | 2185 NOTREACHED() << "Unknown resume mode " << mode; |
| 2181 return "unknown"; | 2186 return "unknown"; |
| 2182 } | 2187 } |
| 2183 | 2188 |
| 2184 } // namespace content | 2189 } // namespace content |
| OLD | NEW |