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

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

Issue 1739503002: Makes the OfflinePageBridge.getAllPages method asynchronous. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix some comments. Created 4 years, 8 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 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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 // Make a copy of the cached item and update it. The cached item should only 221 // Make a copy of the cached item and update it. The cached item should only
222 // be updated upon the successful store operation. 222 // be updated upon the successful store operation.
223 OfflinePageItem offline_page_item = iter->second; 223 OfflinePageItem offline_page_item = iter->second;
224 offline_page_item.MarkForDeletion(); 224 offline_page_item.MarkForDeletion();
225 store_->AddOrUpdateOfflinePage( 225 store_->AddOrUpdateOfflinePage(
226 offline_page_item, 226 offline_page_item,
227 base::Bind(&OfflinePageModel::OnMarkPageForDeletionDone, 227 base::Bind(&OfflinePageModel::OnMarkPageForDeletionDone,
228 weak_ptr_factory_.GetWeakPtr(), offline_page_item, callback)); 228 weak_ptr_factory_.GetWeakPtr(), offline_page_item, callback));
229 } 229 }
230 230
231 void OfflinePageModel::DeletePageByOfflineId(
232 int64_t offline_id,
233 const DeletePageCallback& callback) {
234 DCHECK(is_loaded_);
235 std::vector<int64_t> offline_ids_to_delete;
236 offline_ids_to_delete.push_back(offline_id);
237 DeletePagesByOfflineId(offline_ids_to_delete, callback);
238 }
239
240 void OfflinePageModel::DeletePagesByOfflineId( 231 void OfflinePageModel::DeletePagesByOfflineId(
241 const std::vector<int64_t>& offline_ids, 232 const std::vector<int64_t>& offline_ids,
242 const DeletePageCallback& callback) { 233 const DeletePageCallback& callback) {
243 if (!is_loaded_) { 234 if (!is_loaded_) {
244 delayed_tasks_.push_back( 235 delayed_tasks_.push_back(
245 base::Bind(&OfflinePageModel::DoDeletePagesByOfflineId, 236 base::Bind(&OfflinePageModel::DoDeletePagesByOfflineId,
246 weak_ptr_factory_.GetWeakPtr(), offline_ids, callback)); 237 weak_ptr_factory_.GetWeakPtr(), offline_ids, callback));
247 238
248 return; 239 return;
249 } 240 }
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 base::Bind(&OfflinePageModel::MarkPageForDeletion, 779 base::Bind(&OfflinePageModel::MarkPageForDeletion,
789 weak_ptr_factory_.GetWeakPtr(), offline_ids[i], callback)); 780 weak_ptr_factory_.GetWeakPtr(), offline_ids[i], callback));
790 } 781 }
791 return; 782 return;
792 } 783 }
793 for (const auto& id : offline_ids) { 784 for (const auto& id : offline_ids) {
794 MarkPageForDeletion(id, callback); 785 MarkPageForDeletion(id, callback);
795 } 786 }
796 } 787 }
797 } // namespace offline_pages 788 } // namespace offline_pages
OLDNEW
« no previous file with comments | « chrome/browser/android/offline_pages/offline_page_bridge.cc ('k') | components/offline_pages/offline_page_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698