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 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 for (SaveUrlItemMap::iterator it = saved_failed_items_.begin(); | 740 for (SaveUrlItemMap::iterator it = saved_failed_items_.begin(); |
741 it != saved_failed_items_.end(); ++it) | 741 it != saved_failed_items_.end(); ++it) |
742 save_ids.push_back(it->second->save_id()); | 742 save_ids.push_back(it->second->save_id()); |
743 | 743 |
744 BrowserThread::PostTask( | 744 BrowserThread::PostTask( |
745 BrowserThread::FILE, FROM_HERE, | 745 BrowserThread::FILE, FROM_HERE, |
746 base::Bind(&SaveFileManager::RemoveSavedFileFromFileMap, | 746 base::Bind(&SaveFileManager::RemoveSavedFileFromFileMap, |
747 file_manager_, | 747 file_manager_, |
748 save_ids)); | 748 save_ids)); |
749 | 749 |
750 // Hack to avoid touching download_ after user cancel. | 750 if (download_) { |
751 // TODO(rdsmith/benjhayden): Integrate canceling on DownloadItem | 751 // Hack to avoid touching download_ after user cancel. |
752 // with SavePackage flow. | 752 // TODO(rdsmith/benjhayden): Integrate canceling on DownloadItem |
753 if (download_ && download_->IsInProgress()) { | 753 // with SavePackage flow. |
754 if (save_type_ != content::SAVE_PAGE_TYPE_AS_MHTML) { | 754 if (download_->IsInProgress()) { |
755 download_->OnAllDataSaved(all_save_items_count_, | 755 if (save_type_ != content::SAVE_PAGE_TYPE_AS_MHTML) { |
756 DownloadItem::kEmptyFileHash); | 756 download_->OnAllDataSaved(all_save_items_count_, |
| 757 DownloadItem::kEmptyFileHash); |
| 758 } |
| 759 download_->MarkAsComplete(); |
757 } | 760 } |
758 download_->MarkAsComplete(); | 761 FinalizeDownloadEntry(); |
759 } | 762 } |
760 FinalizeDownloadEntry(); | |
761 } | 763 } |
762 | 764 |
763 // Called for updating end state. | 765 // Called for updating end state. |
764 void SavePackage::SaveFinished(int32 save_id, int64 size, bool is_success) { | 766 void SavePackage::SaveFinished(int32 save_id, int64 size, bool is_success) { |
765 // Because we might have canceled this saving job before, | 767 // Because we might have canceled this saving job before, |
766 // so we might not find corresponding SaveItem. Just ignore it. | 768 // so we might not find corresponding SaveItem. Just ignore it. |
767 SaveItem* save_item = LookupItemInProcessBySaveId(save_id); | 769 SaveItem* save_item = LookupItemInProcessBySaveId(save_id); |
768 if (!save_item) | 770 if (!save_item) |
769 return; | 771 return; |
770 | 772 |
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1391 // central SavePackage related location that observers can | 1393 // central SavePackage related location that observers can |
1392 // get to if they want to wait for notifications for a | 1394 // get to if they want to wait for notifications for a |
1393 // particular BrowserContext. Alternatively, we could make | 1395 // particular BrowserContext. Alternatively, we could make |
1394 // it come from the WebContents, which would be more specific | 1396 // it come from the WebContents, which would be more specific |
1395 // but less useful to (current) customers. | 1397 // but less useful to (current) customers. |
1396 content::Source<content::DownloadManager>(download_manager_), | 1398 content::Source<content::DownloadManager>(download_manager_), |
1397 content::Details<content::DownloadItem>(download_)); | 1399 content::Details<content::DownloadItem>(download_)); |
1398 download_manager_->SavePageDownloadFinished(download_); | 1400 download_manager_->SavePageDownloadFinished(download_); |
1399 StopObservation(); | 1401 StopObservation(); |
1400 } | 1402 } |
OLD | NEW |