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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 last_reason_ = user_cancel ? | 340 last_reason_ = user_cancel ? |
341 DOWNLOAD_INTERRUPT_REASON_USER_CANCELED : | 341 DOWNLOAD_INTERRUPT_REASON_USER_CANCELED : |
342 DOWNLOAD_INTERRUPT_REASON_USER_SHUTDOWN; | 342 DOWNLOAD_INTERRUPT_REASON_USER_SHUTDOWN; |
343 | 343 |
344 RecordDownloadCount(CANCELLED_COUNT); | 344 RecordDownloadCount(CANCELLED_COUNT); |
345 | 345 |
346 // TODO(rdsmith/benjhayden): Remove condition as part of | 346 // TODO(rdsmith/benjhayden): Remove condition as part of |
347 // |SavePackage| integration. | 347 // |SavePackage| integration. |
348 // |download_file_| can be NULL if Interrupt() is called after the | 348 // |download_file_| can be NULL if Interrupt() is called after the |
349 // download file has been released. | 349 // download file has been released. |
350 if (!is_save_package_download_ && download_file_.get()) | 350 if (!is_save_package_download_ && download_file_) |
351 ReleaseDownloadFile(true); | 351 ReleaseDownloadFile(true); |
352 | 352 |
353 if (state_ != INTERRUPTED_INTERNAL) { | 353 if (state_ != INTERRUPTED_INTERNAL) { |
354 // Cancel the originating URL request unless it's already been cancelled | 354 // Cancel the originating URL request unless it's already been cancelled |
355 // by interrupt. | 355 // by interrupt. |
356 request_handle_->CancelRequest(); | 356 request_handle_->CancelRequest(); |
357 } | 357 } |
358 | 358 |
359 TransitionTo(CANCELLED_INTERNAL); | 359 TransitionTo(CANCELLED_INTERNAL); |
360 } | 360 } |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 | 681 |
682 BrowserContext* DownloadItemImpl::GetBrowserContext() const { | 682 BrowserContext* DownloadItemImpl::GetBrowserContext() const { |
683 return delegate_->GetBrowserContext(); | 683 return delegate_->GetBrowserContext(); |
684 } | 684 } |
685 | 685 |
686 WebContents* DownloadItemImpl::GetWebContents() const { | 686 WebContents* DownloadItemImpl::GetWebContents() const { |
687 // TODO(rdsmith): Remove null check after removing GetWebContents() from | 687 // TODO(rdsmith): Remove null check after removing GetWebContents() from |
688 // paths that might be used by DownloadItems created from history import. | 688 // paths that might be used by DownloadItems created from history import. |
689 // Currently such items have null request_handle_s, where other items | 689 // Currently such items have null request_handle_s, where other items |
690 // (regular and SavePackage downloads) have actual objects off the pointer. | 690 // (regular and SavePackage downloads) have actual objects off the pointer. |
691 if (request_handle_.get()) | 691 if (request_handle_) |
692 return request_handle_->GetWebContents(); | 692 return request_handle_->GetWebContents(); |
693 return NULL; | 693 return NULL; |
694 } | 694 } |
695 | 695 |
696 void DownloadItemImpl::OnContentCheckCompleted(DownloadDangerType danger_type) { | 696 void DownloadItemImpl::OnContentCheckCompleted(DownloadDangerType danger_type) { |
697 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 697 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
698 DCHECK(AllDataSaved()); | 698 DCHECK(AllDataSaved()); |
699 VLOG(20) << __FUNCTION__ << " danger_type=" << danger_type | 699 VLOG(20) << __FUNCTION__ << " danger_type=" << danger_type |
700 << " download=" << DebugString(true); | 700 << " download=" << DebugString(true); |
701 SetDangerType(danger_type); | 701 SetDangerType(danger_type); |
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1445 } | 1445 } |
1446 // Don't accept any more messages from the DownloadFile, and null | 1446 // Don't accept any more messages from the DownloadFile, and null |
1447 // out any previous "all data received". This also breaks links to | 1447 // out any previous "all data received". This also breaks links to |
1448 // other entities we've given out weak pointers to. | 1448 // other entities we've given out weak pointers to. |
1449 weak_ptr_factory_.InvalidateWeakPtrs(); | 1449 weak_ptr_factory_.InvalidateWeakPtrs(); |
1450 | 1450 |
1451 // TODO(rdsmith/benjhayden): Remove condition as part of | 1451 // TODO(rdsmith/benjhayden): Remove condition as part of |
1452 // |SavePackage| integration. | 1452 // |SavePackage| integration. |
1453 // |download_file_| can be NULL if Interrupt() is called after the | 1453 // |download_file_| can be NULL if Interrupt() is called after the |
1454 // download file has been released. | 1454 // download file has been released. |
1455 if (!is_save_package_download_ && download_file_.get()) { | 1455 if (!is_save_package_download_ && download_file_) { |
1456 BrowserThread::PostTask( | 1456 BrowserThread::PostTask( |
1457 BrowserThread::FILE, FROM_HERE, | 1457 BrowserThread::FILE, FROM_HERE, |
1458 // Will be deleted at end of task execution. | 1458 // Will be deleted at end of task execution. |
1459 base::Bind(&DownloadFileCancel, base::Passed(&download_file_))); | 1459 base::Bind(&DownloadFileCancel, base::Passed(&download_file_))); |
1460 } | 1460 } |
1461 } | 1461 } |
1462 | 1462 |
1463 bool DownloadItemImpl::IsDownloadReadyForCompletion( | 1463 bool DownloadItemImpl::IsDownloadReadyForCompletion( |
1464 const base::Closure& state_change_notification) { | 1464 const base::Closure& state_change_notification) { |
1465 // If we don't have all the data, the download is not ready for | 1465 // If we don't have all the data, the download is not ready for |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1673 case RESUME_MODE_USER_CONTINUE: | 1673 case RESUME_MODE_USER_CONTINUE: |
1674 return "USER_CONTINUE"; | 1674 return "USER_CONTINUE"; |
1675 case RESUME_MODE_USER_RESTART: | 1675 case RESUME_MODE_USER_RESTART: |
1676 return "USER_RESTART"; | 1676 return "USER_RESTART"; |
1677 } | 1677 } |
1678 NOTREACHED() << "Unknown resume mode " << mode; | 1678 NOTREACHED() << "Unknown resume mode " << mode; |
1679 return "unknown"; | 1679 return "unknown"; |
1680 } | 1680 } |
1681 | 1681 |
1682 } // namespace content | 1682 } // namespace content |
OLD | NEW |