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

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

Issue 2434993002: Add methods to Reading List Model (Closed)
Patch Set: Remove ClearModelForTest 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 7951622fa0c210fdee11a192c4744ce841f04a8f..a07f7f2b98851361e0189072cbb15d52b9c7df3f 100644
--- a/ios/chrome/browser/reading_list/reading_list_model_impl.cc
+++ b/ios/chrome/browser/reading_list/reading_list_model_impl.cc
@@ -138,6 +138,30 @@ const ReadingListEntry& ReadingListModelImpl::AddEntry(
return *unread_.begin();
}
+void ReadingListModelImpl::MarkUnreadByURL(const GURL& url) {
+ DCHECK(loaded());
+ ReadingListEntry entry(url, std::string());
+ auto result = std::find(read_.begin(), read_.end(), entry);
+ if (result == read_.end())
+ return;
+
+ for (ReadingListModelObserver& observer : observers_) {
+ observer.ReadingListWillMoveEntry(this,
+ std::distance(read_.begin(), result));
+ }
+
+ unread_.insert(unread_.begin(), std::move(*result));
+ read_.erase(result);
+
+ if (storageLayer_ && !IsPerformingBatchUpdates()) {
+ storageLayer_->SavePersistentUnreadList(read_);
+ storageLayer_->SavePersistentReadList(unread_);
+ }
+ for (ReadingListModelObserver& observer : observers_) {
+ observer.ReadingListDidApplyChanges(this);
+ }
+}
+
void ReadingListModelImpl::MarkReadByURL(const GURL& url) {
DCHECK(loaded());
ReadingListEntry entry(url, std::string());

Powered by Google App Engine
This is Rietveld 408576698