| 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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 // Make a copy of the cached item and update it. The cached item should only | 219 // Make a copy of the cached item and update it. The cached item should only |
| 220 // be updated upon the successful store operation. | 220 // be updated upon the successful store operation. |
| 221 OfflinePageItem offline_page_item = iter->second; | 221 OfflinePageItem offline_page_item = iter->second; |
| 222 offline_page_item.MarkForDeletion(); | 222 offline_page_item.MarkForDeletion(); |
| 223 store_->AddOrUpdateOfflinePage( | 223 store_->AddOrUpdateOfflinePage( |
| 224 offline_page_item, | 224 offline_page_item, |
| 225 base::Bind(&OfflinePageModel::OnMarkPageForDeletionDone, | 225 base::Bind(&OfflinePageModel::OnMarkPageForDeletionDone, |
| 226 weak_ptr_factory_.GetWeakPtr(), offline_page_item, callback)); | 226 weak_ptr_factory_.GetWeakPtr(), offline_page_item, callback)); |
| 227 } | 227 } |
| 228 | 228 |
| 229 void OfflinePageModel::DeletePageByOfflineId( | |
| 230 int64_t offline_id, | |
| 231 const DeletePageCallback& callback) { | |
| 232 DCHECK(is_loaded_); | |
| 233 std::vector<int64_t> offline_ids_to_delete; | |
| 234 offline_ids_to_delete.push_back(offline_id); | |
| 235 DeletePagesByOfflineId(offline_ids_to_delete, callback); | |
| 236 } | |
| 237 | |
| 238 void OfflinePageModel::DeletePagesByOfflineId( | 229 void OfflinePageModel::DeletePagesByOfflineId( |
| 239 const std::vector<int64_t>& offline_ids, | 230 const std::vector<int64_t>& offline_ids, |
| 240 const DeletePageCallback& callback) { | 231 const DeletePageCallback& callback) { |
| 241 if (!is_loaded_) { | 232 if (!is_loaded_) { |
| 242 delayed_tasks_.push_back( | 233 delayed_tasks_.push_back( |
| 243 base::Bind(&OfflinePageModel::DoDeletePagesByOfflineId, | 234 base::Bind(&OfflinePageModel::DoDeletePagesByOfflineId, |
| 244 weak_ptr_factory_.GetWeakPtr(), offline_ids, callback)); | 235 weak_ptr_factory_.GetWeakPtr(), offline_ids, callback)); |
| 245 | 236 |
| 246 return; | 237 return; |
| 247 } | 238 } |
| (...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 base::Bind(&OfflinePageModel::MarkPageForDeletion, | 777 base::Bind(&OfflinePageModel::MarkPageForDeletion, |
| 787 weak_ptr_factory_.GetWeakPtr(), offline_ids[i], callback)); | 778 weak_ptr_factory_.GetWeakPtr(), offline_ids[i], callback)); |
| 788 } | 779 } |
| 789 return; | 780 return; |
| 790 } | 781 } |
| 791 for (const auto& id : offline_ids) { | 782 for (const auto& id : offline_ids) { |
| 792 MarkPageForDeletion(id, callback); | 783 MarkPageForDeletion(id, callback); |
| 793 } | 784 } |
| 794 } | 785 } |
| 795 } // namespace offline_pages | 786 } // namespace offline_pages |
| OLD | NEW |