| 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 #include "content/browser/download/save_package.h" | 5 #include "content/browser/download/save_package.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 BrowserThread::FILE, FROM_HERE, | 703 BrowserThread::FILE, FROM_HERE, |
| 704 base::Bind(&SaveFileManager::RemoveSavedFileFromFileMap, file_manager_, | 704 base::Bind(&SaveFileManager::RemoveSavedFileFromFileMap, file_manager_, |
| 705 list_of_failed_save_item_ids)); | 705 list_of_failed_save_item_ids)); |
| 706 | 706 |
| 707 if (download_) { | 707 if (download_) { |
| 708 // Hack to avoid touching |download_| after user cancel. | 708 // Hack to avoid touching |download_| after user cancel. |
| 709 // TODO(rdsmith/benjhayden): Integrate canceling on DownloadItem | 709 // TODO(rdsmith/benjhayden): Integrate canceling on DownloadItem |
| 710 // with SavePackage flow. | 710 // with SavePackage flow. |
| 711 if (download_->GetState() == DownloadItem::IN_PROGRESS) { | 711 if (download_->GetState() == DownloadItem::IN_PROGRESS) { |
| 712 if (save_type_ != SAVE_PAGE_TYPE_AS_MHTML) { | 712 if (save_type_ != SAVE_PAGE_TYPE_AS_MHTML) { |
| 713 download_->DestinationUpdate(all_save_items_count_, CurrentSpeed()); | 713 download_->DestinationUpdate( |
| 714 all_save_items_count_, CurrentSpeed(), |
| 715 std::vector<DownloadItem::ReceivedSlice>()); |
| 714 download_->OnAllDataSaved(all_save_items_count_, | 716 download_->OnAllDataSaved(all_save_items_count_, |
| 715 std::unique_ptr<crypto::SecureHash>()); | 717 std::unique_ptr<crypto::SecureHash>()); |
| 716 } | 718 } |
| 717 download_->MarkAsComplete(); | 719 download_->MarkAsComplete(); |
| 718 } | 720 } |
| 719 FinalizeDownloadEntry(); | 721 FinalizeDownloadEntry(); |
| 720 } | 722 } |
| 721 } | 723 } |
| 722 | 724 |
| 723 void SavePackage::SaveFinished(SaveItemId save_item_id, | 725 void SavePackage::SaveFinished(SaveItemId save_item_id, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 736 file_manager_->RemoveSaveFile(save_item->id(), this); | 738 file_manager_->RemoveSaveFile(save_item->id(), this); |
| 737 | 739 |
| 738 PutInProgressItemToSavedMap(save_item); | 740 PutInProgressItemToSavedMap(save_item); |
| 739 | 741 |
| 740 // Inform the DownloadItem to update UI. | 742 // Inform the DownloadItem to update UI. |
| 741 // We use the received bytes as number of saved files. | 743 // We use the received bytes as number of saved files. |
| 742 // Hack to avoid touching download_ after user cancel. | 744 // Hack to avoid touching download_ after user cancel. |
| 743 // TODO(rdsmith/benjhayden): Integrate canceling on DownloadItem | 745 // TODO(rdsmith/benjhayden): Integrate canceling on DownloadItem |
| 744 // with SavePackage flow. | 746 // with SavePackage flow. |
| 745 if (download_ && (download_->GetState() == DownloadItem::IN_PROGRESS)) { | 747 if (download_ && (download_->GetState() == DownloadItem::IN_PROGRESS)) { |
| 746 download_->DestinationUpdate(completed_count(), CurrentSpeed()); | 748 download_->DestinationUpdate( |
| 749 completed_count(), CurrentSpeed(), |
| 750 std::vector<DownloadItem::ReceivedSlice>()); |
| 747 } | 751 } |
| 748 | 752 |
| 749 if (save_item->save_source() == SaveFileCreateInfo::SAVE_FILE_FROM_DOM && | 753 if (save_item->save_source() == SaveFileCreateInfo::SAVE_FILE_FROM_DOM && |
| 750 save_item->url() == page_url_ && !save_item->received_bytes()) { | 754 save_item->url() == page_url_ && !save_item->received_bytes()) { |
| 751 // If size of main HTML page is 0, treat it as disk error. | 755 // If size of main HTML page is 0, treat it as disk error. |
| 752 Cancel(false); | 756 Cancel(false); |
| 753 return; | 757 return; |
| 754 } | 758 } |
| 755 | 759 |
| 756 if (canceled()) { | 760 if (canceled()) { |
| (...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1481 } | 1485 } |
| 1482 | 1486 |
| 1483 void SavePackage::FinalizeDownloadEntry() { | 1487 void SavePackage::FinalizeDownloadEntry() { |
| 1484 DCHECK(download_); | 1488 DCHECK(download_); |
| 1485 | 1489 |
| 1486 download_manager_->OnSavePackageSuccessfullyFinished(download_); | 1490 download_manager_->OnSavePackageSuccessfullyFinished(download_); |
| 1487 RemoveObservers(); | 1491 RemoveObservers(); |
| 1488 } | 1492 } |
| 1489 | 1493 |
| 1490 } // namespace content | 1494 } // namespace content |
| OLD | NEW |