| Index: components/reading_list/ios/reading_list_model_impl.cc
|
| diff --git a/components/reading_list/ios/reading_list_model_impl.cc b/components/reading_list/ios/reading_list_model_impl.cc
|
| index e310b6040d3d756ae8b4714ab8c2fa84ca347d2f..fef295916b7f5c7d9a8387435f5f2c61205f756c 100644
|
| --- a/components/reading_list/ios/reading_list_model_impl.cc
|
| +++ b/components/reading_list/ios/reading_list_model_impl.cc
|
| @@ -170,6 +170,40 @@ const ReadingListEntry* ReadingListModelImpl::GetEntryByURL(
|
| return GetMutableEntryFromURL(gurl);
|
| }
|
|
|
| +const ReadingListEntry* ReadingListModelImpl::GetFirstUnreadEntry(
|
| + bool distilled) const {
|
| + DCHECK(CalledOnValidThread());
|
| + DCHECK(loaded());
|
| + if (unread_entry_count_ == 0) {
|
| + return nullptr;
|
| + }
|
| + int64_t update_time_all = 0;
|
| + const ReadingListEntry* first_entry_all = nullptr;
|
| + int64_t update_time_distilled = 0;
|
| + const ReadingListEntry* first_entry_distilled = nullptr;
|
| + for (auto& iterator : *entries_) {
|
| + ReadingListEntry& entry = iterator.second;
|
| + if (entry.IsRead()) {
|
| + continue;
|
| + }
|
| + if (entry.UpdateTime() > update_time_all) {
|
| + update_time_all = entry.UpdateTime();
|
| + first_entry_all = &entry;
|
| + }
|
| + if (entry.DistilledState() == ReadingListEntry::PROCESSED &&
|
| + entry.UpdateTime() > update_time_distilled) {
|
| + update_time_distilled = entry.UpdateTime();
|
| + first_entry_distilled = &entry;
|
| + }
|
| + }
|
| + DCHECK(first_entry_all);
|
| + DCHECK_GT(update_time_all, 0);
|
| + if (distilled && first_entry_distilled) {
|
| + return first_entry_distilled;
|
| + }
|
| + return first_entry_all;
|
| +}
|
| +
|
| ReadingListEntry* ReadingListModelImpl::GetMutableEntryFromURL(
|
| const GURL& url) const {
|
| DCHECK(CalledOnValidThread());
|
|
|