| 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/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 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 callback.Run(result); | 444 callback.Run(result); |
| 445 } | 445 } |
| 446 | 446 |
| 447 void OfflinePageModelImpl::GetAllPages( | 447 void OfflinePageModelImpl::GetAllPages( |
| 448 const MultipleOfflinePageItemCallback& callback) { | 448 const MultipleOfflinePageItemCallback& callback) { |
| 449 RunWhenLoaded(base::Bind(&OfflinePageModelImpl::GetAllPagesAfterLoadDone, | 449 RunWhenLoaded(base::Bind(&OfflinePageModelImpl::GetAllPagesAfterLoadDone, |
| 450 weak_ptr_factory_.GetWeakPtr(), callback)); | 450 weak_ptr_factory_.GetWeakPtr(), callback)); |
| 451 } | 451 } |
| 452 | 452 |
| 453 void OfflinePageModelImpl::GetAllPagesAfterLoadDone( | 453 void OfflinePageModelImpl::GetAllPagesAfterLoadDone( |
| 454 const MultipleOfflinePageItemCallback& callback) { | 454 const MultipleOfflinePageItemCallback& callback) const { |
| 455 DCHECK(is_loaded_); | 455 DCHECK(is_loaded_); |
| 456 | 456 |
| 457 MultipleOfflinePageItemResult offline_pages; | 457 MultipleOfflinePageItemResult offline_pages; |
| 458 for (const auto& id_page_pair : offline_pages_) | 458 for (const auto& id_page_pair : offline_pages_) |
| 459 offline_pages.push_back(id_page_pair.second); | 459 offline_pages.push_back(id_page_pair.second); |
| 460 | 460 |
| 461 callback.Run(offline_pages); | 461 callback.Run(offline_pages); |
| 462 } | 462 } |
| 463 | 463 |
| 464 void OfflinePageModelImpl::GetOfflineIdsForClientId( | 464 void OfflinePageModelImpl::GetOfflineIdsForClientId( |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 953 void OfflinePageModelImpl::RunWhenLoaded(const base::Closure& task) { | 953 void OfflinePageModelImpl::RunWhenLoaded(const base::Closure& task) { |
| 954 if (!is_loaded_) { | 954 if (!is_loaded_) { |
| 955 delayed_tasks_.push_back(task); | 955 delayed_tasks_.push_back(task); |
| 956 return; | 956 return; |
| 957 } | 957 } |
| 958 | 958 |
| 959 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task); | 959 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task); |
| 960 } | 960 } |
| 961 | 961 |
| 962 } // namespace offline_pages | 962 } // namespace offline_pages |
| OLD | NEW |