Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1188)

Unified Diff: components/reading_list/ios/reading_list_model_impl.cc

Issue 2607523002: Reading List: Open distilled article first if no network. (Closed)
Patch Set: add guards Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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());

Powered by Google App Engine
This is Rietveld 408576698