| 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 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 const MultipleOfflineIdCallback& callback) const { | 519 const MultipleOfflineIdCallback& callback) const { |
| 520 callback.Run(MaybeGetOfflineIdsForClientId(client_id)); | 520 callback.Run(MaybeGetOfflineIdsForClientId(client_id)); |
| 521 } | 521 } |
| 522 | 522 |
| 523 const std::vector<int64_t> OfflinePageModelImpl::MaybeGetOfflineIdsForClientId( | 523 const std::vector<int64_t> OfflinePageModelImpl::MaybeGetOfflineIdsForClientId( |
| 524 const ClientId& client_id) const { | 524 const ClientId& client_id) const { |
| 525 DCHECK(is_loaded_); | 525 DCHECK(is_loaded_); |
| 526 std::vector<int64_t> results; | 526 std::vector<int64_t> results; |
| 527 | 527 |
| 528 // We want only all pages, including those marked for deletion. | 528 // We want only all pages, including those marked for deletion. |
| 529 // TODO(bburns): actually use an index rather than linear scan. | 529 // TODO(fgorski): actually use an index rather than linear scan. |
| 530 for (const auto& id_page_pair : offline_pages_) { | 530 for (const auto& id_page_pair : offline_pages_) { |
| 531 if (id_page_pair.second.client_id == client_id && | 531 if (id_page_pair.second.client_id == client_id && |
| 532 !id_page_pair.second.IsExpired()) { | 532 !id_page_pair.second.IsExpired()) { |
| 533 results.push_back(id_page_pair.second.offline_id); | 533 results.push_back(id_page_pair.second.offline_id); |
| 534 } | 534 } |
| 535 } | 535 } |
| 536 return results; | 536 return results; |
| 537 } | 537 } |
| 538 | 538 |
| 539 void OfflinePageModelImpl::GetPageByOfflineId( | 539 void OfflinePageModelImpl::GetPageByOfflineId( |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1048 } | 1048 } |
| 1049 | 1049 |
| 1050 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task); | 1050 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task); |
| 1051 } | 1051 } |
| 1052 | 1052 |
| 1053 base::Time OfflinePageModelImpl::GetCurrentTime() const { | 1053 base::Time OfflinePageModelImpl::GetCurrentTime() const { |
| 1054 return testing_clock_ ? testing_clock_->Now() : base::Time::Now(); | 1054 return testing_clock_ ? testing_clock_->Now() : base::Time::Now(); |
| 1055 } | 1055 } |
| 1056 | 1056 |
| 1057 } // namespace offline_pages | 1057 } // namespace offline_pages |
| OLD | NEW |