| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/offline_pages/offline_page_model.h" | 5 #include "components/offline_pages/offline_page_model.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 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 for (const auto& delayed_task : delayed_tasks_) | 536 for (const auto& delayed_task : delayed_tasks_) |
| 537 delayed_task.Run(); | 537 delayed_task.Run(); |
| 538 delayed_tasks_.clear(); | 538 delayed_tasks_.clear(); |
| 539 | 539 |
| 540 // If there are pages that are marked for deletion, but not yet deleted and | 540 // If there are pages that are marked for deletion, but not yet deleted and |
| 541 // OfflinePageModel gets reloaded. Delete the pages now. | 541 // OfflinePageModel gets reloaded. Delete the pages now. |
| 542 FinalizePageDeletion(); | 542 FinalizePageDeletion(); |
| 543 | 543 |
| 544 FOR_EACH_OBSERVER(Observer, observers_, OfflinePageModelLoaded(this)); | 544 FOR_EACH_OBSERVER(Observer, observers_, OfflinePageModelLoaded(this)); |
| 545 | 545 |
| 546 DVLOG(1) << "Store is loaded by now"; |
| 546 CheckForExternalFileDeletion(); | 547 CheckForExternalFileDeletion(); |
| 547 } | 548 } |
| 548 | 549 |
| 549 void OfflinePageModel::InformSavePageDone(const SavePageCallback& callback, | 550 void OfflinePageModel::InformSavePageDone(const SavePageCallback& callback, |
| 550 SavePageResult result) { | 551 SavePageResult result) { |
| 551 UMA_HISTOGRAM_ENUMERATION( | 552 UMA_HISTOGRAM_ENUMERATION( |
| 552 "OfflinePages.SavePageResult", | 553 "OfflinePages.SavePageResult", |
| 553 static_cast<int>(result), | 554 static_cast<int>(result), |
| 554 static_cast<int>(SavePageResult::RESULT_COUNT)); | 555 static_cast<int>(SavePageResult::RESULT_COUNT)); |
| 555 callback.Run(result); | 556 callback.Run(result); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 "OfflinePages.DeletePageResult", | 641 "OfflinePages.DeletePageResult", |
| 641 static_cast<int>(result), | 642 static_cast<int>(result), |
| 642 static_cast<int>(DeletePageResult::RESULT_COUNT)); | 643 static_cast<int>(DeletePageResult::RESULT_COUNT)); |
| 643 if (!callback.is_null()) | 644 if (!callback.is_null()) |
| 644 callback.Run(result); | 645 callback.Run(result); |
| 645 } | 646 } |
| 646 | 647 |
| 647 void OfflinePageModel::OnFindPagesMissingArchiveFile( | 648 void OfflinePageModel::OnFindPagesMissingArchiveFile( |
| 648 const std::vector<int64>* ids_of_pages_missing_archive_file) { | 649 const std::vector<int64>* ids_of_pages_missing_archive_file) { |
| 649 DCHECK(ids_of_pages_missing_archive_file); | 650 DCHECK(ids_of_pages_missing_archive_file); |
| 651 DVLOG(1) << "Found " << ids_of_pages_missing_archive_file->size() |
| 652 << " page(s) missing an archive file."; |
| 653 |
| 650 if (ids_of_pages_missing_archive_file->empty()) | 654 if (ids_of_pages_missing_archive_file->empty()) |
| 651 return; | 655 return; |
| 652 | 656 |
| 653 DeletePageCallback done_callback( | 657 DeletePageCallback done_callback( |
| 654 base::Bind(&OfflinePageModel::OnRemoveOfflinePagesMissingArchiveFileDone, | 658 base::Bind(&OfflinePageModel::OnRemoveOfflinePagesMissingArchiveFileDone, |
| 655 weak_ptr_factory_.GetWeakPtr(), | 659 weak_ptr_factory_.GetWeakPtr(), |
| 656 *ids_of_pages_missing_archive_file)); | 660 *ids_of_pages_missing_archive_file)); |
| 657 | 661 |
| 658 store_->RemoveOfflinePages( | 662 store_->RemoveOfflinePages( |
| 659 *ids_of_pages_missing_archive_file, | 663 *ids_of_pages_missing_archive_file, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 load_status == OfflinePageMetadataStore::LOAD_SUCCEEDED ? | 706 load_status == OfflinePageMetadataStore::LOAD_SUCCEEDED ? |
| 703 CLEAR_ALL_SUCCEEDED : STORE_RELOAD_FAILED, | 707 CLEAR_ALL_SUCCEEDED : STORE_RELOAD_FAILED, |
| 704 CLEAR_ALL_STATUS_COUNT); | 708 CLEAR_ALL_STATUS_COUNT); |
| 705 | 709 |
| 706 CacheLoadedData(offline_pages); | 710 CacheLoadedData(offline_pages); |
| 707 callback.Run(); | 711 callback.Run(); |
| 708 } | 712 } |
| 709 | 713 |
| 710 void OfflinePageModel::CacheLoadedData( | 714 void OfflinePageModel::CacheLoadedData( |
| 711 const std::vector<OfflinePageItem>& offline_pages) { | 715 const std::vector<OfflinePageItem>& offline_pages) { |
| 716 DVLOG(1) << "Caching offline pages, count: " << offline_pages.size(); |
| 712 offline_pages_.clear(); | 717 offline_pages_.clear(); |
| 713 for (const auto& offline_page : offline_pages) | 718 for (const auto& offline_page : offline_pages) |
| 714 offline_pages_[offline_page.bookmark_id] = offline_page; | 719 offline_pages_[offline_page.bookmark_id] = offline_page; |
| 715 } | 720 } |
| 716 | 721 |
| 717 } // namespace offline_pages | 722 } // namespace offline_pages |
| OLD | NEW |