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

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

Issue 2329283002: [Offline pages] OPM SQL store: moving load to constructor, updating read to GetOfflinePages (Closed)
Patch Set: Addressing CR feedback Created 4 years, 3 months 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_impl.h" 5 #include "components/offline_pages/offline_page_model_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 764
765 // No need to fire OfflinePageModelChanged event since updating access info 765 // No need to fire OfflinePageModelChanged event since updating access info
766 // should not have any impact to the UI. 766 // should not have any impact to the UI.
767 } 767 }
768 768
769 void OfflinePageModelImpl::OnEnsureArchivesDirCreatedDone( 769 void OfflinePageModelImpl::OnEnsureArchivesDirCreatedDone(
770 const base::TimeTicks& start_time) { 770 const base::TimeTicks& start_time) {
771 UMA_HISTOGRAM_TIMES("OfflinePages.Model.ArchiveDirCreationTime", 771 UMA_HISTOGRAM_TIMES("OfflinePages.Model.ArchiveDirCreationTime",
772 base::TimeTicks::Now() - start_time); 772 base::TimeTicks::Now() - start_time);
773 773
774 store_->Load(base::Bind(&OfflinePageModelImpl::OnLoadDone, 774 store_->GetOfflinePages(base::Bind(&OfflinePageModelImpl::OnLoadDone,
775 weak_ptr_factory_.GetWeakPtr(), start_time)); 775 weak_ptr_factory_.GetWeakPtr(),
776 start_time));
776 } 777 }
777 778
778 void OfflinePageModelImpl::OnLoadDone( 779 void OfflinePageModelImpl::OnLoadDone(
779 const base::TimeTicks& start_time, 780 const base::TimeTicks& start_time,
780 OfflinePageMetadataStore::LoadStatus load_status, 781 OfflinePageMetadataStore::LoadStatus load_status,
781 const std::vector<OfflinePageItem>& offline_pages) { 782 const std::vector<OfflinePageItem>& offline_pages) {
782 DCHECK(!is_loaded_); 783 DCHECK(!is_loaded_);
783 is_loaded_ = true; 784 is_loaded_ = true;
784 785
785 // TODO(jianli): rebuild the store upon failure. 786 // TODO(jianli): rebuild the store upon failure.
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 const base::Closure& callback, 998 const base::Closure& callback,
998 bool success) { 999 bool success) {
999 DCHECK(success); 1000 DCHECK(success);
1000 if (!success) { 1001 if (!success) {
1001 offline_event_logger_.RecordStoreClearError(); 1002 offline_event_logger_.RecordStoreClearError();
1002 UMA_HISTOGRAM_ENUMERATION("OfflinePages.ClearAllStatus2", 1003 UMA_HISTOGRAM_ENUMERATION("OfflinePages.ClearAllStatus2",
1003 STORE_RESET_FAILED, CLEAR_ALL_STATUS_COUNT); 1004 STORE_RESET_FAILED, CLEAR_ALL_STATUS_COUNT);
1004 } 1005 }
1005 1006
1006 offline_pages_.clear(); 1007 offline_pages_.clear();
1007 store_->Load(base::Bind(&OfflinePageModelImpl::OnReloadStoreDoneForClearAll, 1008 store_->GetOfflinePages(
1008 weak_ptr_factory_.GetWeakPtr(), callback)); 1009 base::Bind(&OfflinePageModelImpl::OnReloadStoreDoneForClearAll,
1010 weak_ptr_factory_.GetWeakPtr(), callback));
1009 } 1011 }
1010 1012
1011 void OfflinePageModelImpl::OnReloadStoreDoneForClearAll( 1013 void OfflinePageModelImpl::OnReloadStoreDoneForClearAll(
1012 const base::Closure& callback, 1014 const base::Closure& callback,
1013 OfflinePageMetadataStore::LoadStatus load_status, 1015 OfflinePageMetadataStore::LoadStatus load_status,
1014 const std::vector<OfflinePageItem>& offline_pages) { 1016 const std::vector<OfflinePageItem>& offline_pages) {
1015 DCHECK_EQ(OfflinePageMetadataStore::LOAD_SUCCEEDED, load_status); 1017 DCHECK_EQ(OfflinePageMetadataStore::LOAD_SUCCEEDED, load_status);
1016 UMA_HISTOGRAM_ENUMERATION( 1018 UMA_HISTOGRAM_ENUMERATION(
1017 "OfflinePages.ClearAllStatus2", 1019 "OfflinePages.ClearAllStatus2",
1018 load_status == OfflinePageMetadataStore::LOAD_SUCCEEDED 1020 load_status == OfflinePageMetadataStore::LOAD_SUCCEEDED
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 void OfflinePageModelImpl::RunWhenLoaded(const base::Closure& task) { 1072 void OfflinePageModelImpl::RunWhenLoaded(const base::Closure& task) {
1071 if (!is_loaded_) { 1073 if (!is_loaded_) {
1072 delayed_tasks_.push_back(task); 1074 delayed_tasks_.push_back(task);
1073 return; 1075 return;
1074 } 1076 }
1075 1077
1076 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task); 1078 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task);
1077 } 1079 }
1078 1080
1079 } // namespace offline_pages 1081 } // namespace offline_pages
OLDNEW
« no previous file with comments | « components/offline_pages/offline_page_metadata_store_sql.cc ('k') | components/offline_pages/offline_page_test_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698