| OLD | NEW |
| 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/core/offline_page_model_impl.h" | 5 #include "components/offline_pages/core/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 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 builder.SetClientIds(OfflinePageModelQuery::Requirement::INCLUDE_MATCHING, | 445 builder.SetClientIds(OfflinePageModelQuery::Requirement::INCLUDE_MATCHING, |
| 446 client_ids); | 446 client_ids); |
| 447 auto delete_pages = base::Bind(&OfflinePageModelImpl::DeletePages, | 447 auto delete_pages = base::Bind(&OfflinePageModelImpl::DeletePages, |
| 448 weak_ptr_factory_.GetWeakPtr(), callback); | 448 weak_ptr_factory_.GetWeakPtr(), callback); |
| 449 RunWhenLoaded(base::Bind( | 449 RunWhenLoaded(base::Bind( |
| 450 &OfflinePageModelImpl::GetPagesMatchingQueryWhenLoadDone, | 450 &OfflinePageModelImpl::GetPagesMatchingQueryWhenLoadDone, |
| 451 weak_ptr_factory_.GetWeakPtr(), | 451 weak_ptr_factory_.GetWeakPtr(), |
| 452 base::Passed(builder.Build(GetPolicyController())), delete_pages)); | 452 base::Passed(builder.Build(GetPolicyController())), delete_pages)); |
| 453 } | 453 } |
| 454 | 454 |
| 455 void OfflinePageModelImpl::DeletePagesMatchingQuery( |
| 456 std::unique_ptr<OfflinePageModelQuery> query, |
| 457 const DeletePageCallback& callback) { |
| 458 GetPagesMatchingQuery(std::move(query), |
| 459 base::Bind(&OfflinePageModelImpl::DeletePages, |
| 460 weak_ptr_factory_.GetWeakPtr(), callback)); |
| 461 } |
| 462 |
| 455 void OfflinePageModelImpl::DeletePages( | 463 void OfflinePageModelImpl::DeletePages( |
| 456 const DeletePageCallback& callback, | 464 const DeletePageCallback& callback, |
| 457 const MultipleOfflinePageItemResult& pages) { | 465 const MultipleOfflinePageItemResult& pages) { |
| 458 DCHECK(is_loaded_); | 466 DCHECK(is_loaded_); |
| 459 | 467 |
| 460 std::vector<int64_t> offline_ids; | 468 std::vector<int64_t> offline_ids; |
| 461 for (auto& page : pages) | 469 for (auto& page : pages) |
| 462 offline_ids.emplace_back(page.offline_id); | 470 offline_ids.emplace_back(page.offline_id); |
| 463 | 471 |
| 464 DoDeletePagesByOfflineId(offline_ids, callback); | 472 DoDeletePagesByOfflineId(offline_ids, callback); |
| (...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1092 } | 1100 } |
| 1093 | 1101 |
| 1094 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task); | 1102 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task); |
| 1095 } | 1103 } |
| 1096 | 1104 |
| 1097 base::Time OfflinePageModelImpl::GetCurrentTime() const { | 1105 base::Time OfflinePageModelImpl::GetCurrentTime() const { |
| 1098 return testing_clock_ ? testing_clock_->Now() : base::Time::Now(); | 1106 return testing_clock_ ? testing_clock_->Now() : base::Time::Now(); |
| 1099 } | 1107 } |
| 1100 | 1108 |
| 1101 } // namespace offline_pages | 1109 } // namespace offline_pages |
| OLD | NEW |