| 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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |