| 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 1262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1273 } | 1273 } |
| 1274 | 1274 |
| 1275 // Successful download start. | 1275 // Successful download start. |
| 1276 DCHECK(download_file_); | 1276 DCHECK(download_file_); |
| 1277 DCHECK(job_); | 1277 DCHECK(job_); |
| 1278 | 1278 |
| 1279 if (state_ == RESUMING_INTERNAL) | 1279 if (state_ == RESUMING_INTERNAL) |
| 1280 UpdateValidatorsOnResumption(new_create_info); | 1280 UpdateValidatorsOnResumption(new_create_info); |
| 1281 | 1281 |
| 1282 if (state_ == INITIAL_INTERNAL && job_->UsesParallelRequests()) | 1282 if (state_ == INITIAL_INTERNAL && job_->UsesParallelRequests()) |
| 1283 RecordDownloadCount(USES_PARALLEL_REQUESTS); | 1283 RecordParallelDownloadCount(START_COUNT); |
| 1284 | 1284 |
| 1285 TransitionTo(TARGET_PENDING_INTERNAL); | 1285 TransitionTo(TARGET_PENDING_INTERNAL); |
| 1286 | 1286 |
| 1287 job_->Start(); | 1287 job_->Start(); |
| 1288 } | 1288 } |
| 1289 | 1289 |
| 1290 void DownloadItemImpl::StartDownload() { | 1290 void DownloadItemImpl::StartDownload() { |
| 1291 BrowserThread::PostTask( | 1291 BrowserThread::PostTask( |
| 1292 BrowserThread::FILE, FROM_HERE, | 1292 BrowserThread::FILE, FROM_HERE, |
| 1293 base::Bind(&DownloadFile::Initialize, | 1293 base::Bind(&DownloadFile::Initialize, |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1566 | 1566 |
| 1567 DVLOG(20) << __func__ << "() " << DebugString(false); | 1567 DVLOG(20) << __func__ << "() " << DebugString(false); |
| 1568 | 1568 |
| 1569 DCHECK(all_data_saved_); | 1569 DCHECK(all_data_saved_); |
| 1570 end_time_ = base::Time::Now(); | 1570 end_time_ = base::Time::Now(); |
| 1571 TransitionTo(COMPLETE_INTERNAL); | 1571 TransitionTo(COMPLETE_INTERNAL); |
| 1572 RecordDownloadCompleted(start_tick_, received_bytes_); | 1572 RecordDownloadCompleted(start_tick_, received_bytes_); |
| 1573 if (!GetBrowserContext()->IsOffTheRecord()) { | 1573 if (!GetBrowserContext()->IsOffTheRecord()) { |
| 1574 RecordDownloadCount(COMPLETED_COUNT_NORMAL_PROFILE); | 1574 RecordDownloadCount(COMPLETED_COUNT_NORMAL_PROFILE); |
| 1575 } | 1575 } |
| 1576 if (job_ && job_->UsesParallelRequests()) |
| 1577 RecordParallelDownloadCount(COMPLETED_COUNT); |
| 1576 | 1578 |
| 1577 if (auto_opened_) { | 1579 if (auto_opened_) { |
| 1578 // If it was already handled by the delegate, do nothing. | 1580 // If it was already handled by the delegate, do nothing. |
| 1579 } else if (GetOpenWhenComplete() || | 1581 } else if (GetOpenWhenComplete() || |
| 1580 ShouldOpenFileBasedOnExtension() || | 1582 ShouldOpenFileBasedOnExtension() || |
| 1581 IsTemporary()) { | 1583 IsTemporary()) { |
| 1582 // If the download is temporary, like in drag-and-drop, do not open it but | 1584 // If the download is temporary, like in drag-and-drop, do not open it but |
| 1583 // we still need to set it auto-opened so that it can be removed from the | 1585 // we still need to set it auto-opened so that it can be removed from the |
| 1584 // download shelf. | 1586 // download shelf. |
| 1585 if (!IsTemporary()) | 1587 if (!IsTemporary()) |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1696 reason == DOWNLOAD_INTERRUPT_REASON_USER_SHUTDOWN) { | 1698 reason == DOWNLOAD_INTERRUPT_REASON_USER_SHUTDOWN) { |
| 1697 if (IsDangerous()) { | 1699 if (IsDangerous()) { |
| 1698 RecordDangerousDownloadDiscard( | 1700 RecordDangerousDownloadDiscard( |
| 1699 reason == DOWNLOAD_INTERRUPT_REASON_USER_CANCELED | 1701 reason == DOWNLOAD_INTERRUPT_REASON_USER_CANCELED |
| 1700 ? DOWNLOAD_DISCARD_DUE_TO_USER_ACTION | 1702 ? DOWNLOAD_DISCARD_DUE_TO_USER_ACTION |
| 1701 : DOWNLOAD_DISCARD_DUE_TO_SHUTDOWN, | 1703 : DOWNLOAD_DISCARD_DUE_TO_SHUTDOWN, |
| 1702 GetDangerType(), GetTargetFilePath()); | 1704 GetDangerType(), GetTargetFilePath()); |
| 1703 } | 1705 } |
| 1704 | 1706 |
| 1705 RecordDownloadCount(CANCELLED_COUNT); | 1707 RecordDownloadCount(CANCELLED_COUNT); |
| 1708 if (job_ && job_->UsesParallelRequests()) |
| 1709 RecordParallelDownloadCount(CANCELLED_COUNT); |
| 1706 TransitionTo(CANCELLED_INTERNAL); | 1710 TransitionTo(CANCELLED_INTERNAL); |
| 1707 return; | 1711 return; |
| 1708 } | 1712 } |
| 1709 | 1713 |
| 1710 RecordDownloadInterrupted(reason, received_bytes_, total_bytes_); | 1714 RecordDownloadInterrupted(reason, received_bytes_, total_bytes_, |
| 1715 job_ && job_->UsesParallelRequests()); |
| 1711 if (!GetWebContents()) | 1716 if (!GetWebContents()) |
| 1712 RecordDownloadCount(INTERRUPTED_WITHOUT_WEBCONTENTS); | 1717 RecordDownloadCount(INTERRUPTED_WITHOUT_WEBCONTENTS); |
| 1713 | 1718 |
| 1714 TransitionTo(INTERRUPTED_INTERNAL); | 1719 TransitionTo(INTERRUPTED_INTERNAL); |
| 1715 AutoResumeIfValid(); | 1720 AutoResumeIfValid(); |
| 1716 } | 1721 } |
| 1717 | 1722 |
| 1718 void DownloadItemImpl::UpdateProgress( | 1723 void DownloadItemImpl::UpdateProgress( |
| 1719 int64_t bytes_so_far, | 1724 int64_t bytes_so_far, |
| 1720 int64_t bytes_per_sec) { | 1725 int64_t bytes_per_sec) { |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2184 case RESUME_MODE_USER_CONTINUE: | 2189 case RESUME_MODE_USER_CONTINUE: |
| 2185 return "USER_CONTINUE"; | 2190 return "USER_CONTINUE"; |
| 2186 case RESUME_MODE_USER_RESTART: | 2191 case RESUME_MODE_USER_RESTART: |
| 2187 return "USER_RESTART"; | 2192 return "USER_RESTART"; |
| 2188 } | 2193 } |
| 2189 NOTREACHED() << "Unknown resume mode " << mode; | 2194 NOTREACHED() << "Unknown resume mode " << mode; |
| 2190 return "unknown"; | 2195 return "unknown"; |
| 2191 } | 2196 } |
| 2192 | 2197 |
| 2193 } // namespace content | 2198 } // namespace content |
| OLD | NEW |