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

Unified Diff: ios/chrome/browser/reading_list/reading_list_model_impl.cc

Issue 2378123002: Load offline page if reading list entry takes more than 1s to load. (Closed)
Patch Set: Experimental change (reviewers: do not review this PS). Created 4 years, 2 months 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: ios/chrome/browser/reading_list/reading_list_model_impl.cc
diff --git a/ios/chrome/browser/reading_list/reading_list_model_impl.cc b/ios/chrome/browser/reading_list/reading_list_model_impl.cc
index c3e068d65f0249a30a6ce1c36dbd381cdf56d260..a9d29cc59c014fb4b71034ed81194b2506d81abc 100644
--- a/ios/chrome/browser/reading_list/reading_list_model_impl.cc
+++ b/ios/chrome/browser/reading_list/reading_list_model_impl.cc
@@ -54,17 +54,35 @@ void ReadingListModelImpl::ResetUnseenEntries() {
storageLayer_->SavePersistentHasUnseen(false);
}
-// Returns a specific entry.
-const ReadingListEntry& ReadingListModelImpl::GetUnreadEntryAtIndex(
+const ReadingListEntry* ReadingListModelImpl::GetUnreadEntryAtIndex(
size_t index) const {
DCHECK(loaded());
- return unread_[index];
+ if (index >= unread_.size())
+ return nullptr;
+ return &unread_[index];
}
-const ReadingListEntry& ReadingListModelImpl::GetReadEntryAtIndex(
+const ReadingListEntry* ReadingListModelImpl::GetReadEntryAtIndex(
size_t index) const {
DCHECK(loaded());
- return read_[index];
+ if (index >= read_.size())
+ return nullptr;
+ return &read_[index];
+}
+
+const ReadingListEntry* ReadingListModelImpl::GetEntryFromURL(
+ const GURL& gurl) const {
+ auto it = std::find_if(
+ read_.begin(), read_.end(),
+ [&gurl](const ReadingListEntry& entry) { return gurl == entry.URL(); });
+ if (it == read_.end()) {
+ it = std::find_if(
+ unread_.begin(), unread_.end(),
+ [&gurl](const ReadingListEntry& entry) { return gurl == entry.URL(); });
+ if (it == unread_.end())
+ return nullptr;
+ }
+ return &(*it);
}
bool ReadingListModelImpl::CallbackEntryURL(

Powered by Google App Engine
This is Rietveld 408576698