Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: components/offline_pages/offline_page_model.cc

Issue 1521193002: [Offline pages] Refactor URL conversions from TabAndroid (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding temp files Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
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);
650 if (ids_of_pages_missing_archive_file->empty()) 651 if (ids_of_pages_missing_archive_file->empty())
651 return; 652 return;
652 653
653 DeletePageCallback done_callback( 654 DeletePageCallback done_callback(
654 base::Bind(&OfflinePageModel::OnRemoveOfflinePagesMissingArchiveFileDone, 655 base::Bind(&OfflinePageModel::OnRemoveOfflinePagesMissingArchiveFileDone,
655 weak_ptr_factory_.GetWeakPtr(), 656 weak_ptr_factory_.GetWeakPtr(),
656 *ids_of_pages_missing_archive_file)); 657 *ids_of_pages_missing_archive_file));
657 658
659 DVLOG(1) << "Found " << ids_of_pages_missing_archive_file->size()
660 << " of pages missing the archive file.";
661
658 store_->RemoveOfflinePages( 662 store_->RemoveOfflinePages(
659 *ids_of_pages_missing_archive_file, 663 *ids_of_pages_missing_archive_file,
660 base::Bind(&OfflinePageModel::OnRemoveOfflinePagesDone, 664 base::Bind(&OfflinePageModel::OnRemoveOfflinePagesDone,
661 weak_ptr_factory_.GetWeakPtr(), 665 weak_ptr_factory_.GetWeakPtr(),
662 *ids_of_pages_missing_archive_file, 666 *ids_of_pages_missing_archive_file,
663 done_callback)); 667 done_callback));
664 } 668 }
665 669
666 void OfflinePageModel::OnRemoveOfflinePagesMissingArchiveFileDone( 670 void OfflinePageModel::OnRemoveOfflinePagesMissingArchiveFileDone(
667 const std::vector<int64>& bookmark_ids, 671 const std::vector<int64>& bookmark_ids,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
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) {
712 offline_pages_.clear(); 716 offline_pages_.clear();
713 for (const auto& offline_page : offline_pages) 717 for (const auto& offline_page : offline_pages)
714 offline_pages_[offline_page.bookmark_id] = offline_page; 718 offline_pages_[offline_page.bookmark_id] = offline_page;
715 } 719 }
716 720
717 } // namespace offline_pages 721 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698