Chromium Code Reviews| 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..74c1730357fce75476860b81787e5d10a64239b1 100644 |
| --- a/ios/chrome/browser/reading_list/reading_list_model_impl.cc |
| +++ b/ios/chrome/browser/reading_list/reading_list_model_impl.cc |
| @@ -137,6 +137,29 @@ const ReadingListEntry& ReadingListModelImpl::AddEntry( |
| observer.ReadingListDidApplyChanges(this); |
| return *unread_.begin(); |
| } |
| +void ReadingListModelImpl::MarkUnreadByURL(const GURL& url) { |
|
Olivier
2016/10/20 11:25:39
new line
gambard
2016/10/20 11:51:35
Done.
|
| + 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, |
|
Olivier
2016/10/20 11:25:39
Comment on ReadingListWillMoveEntry is explicitly
gambard
2016/10/20 11:51:35
I changed the comment. I don't like using the remo
|
| + 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()); |
| @@ -273,3 +296,12 @@ void ReadingListModelImpl::EndBatchUpdates() { |
| storageLayer_->SavePersistentReadList(read_); |
| storageLayer_->SavePersistentHasUnseen(hasUnseen_); |
| } |
| + |
| +void ReadingListModelImpl::ClearModelForTest() { |
| + for (auto& entry : read_) { |
| + this->RemoveEntryByUrl(entry.URL()); |
| + } |
| + for (auto& entry : unread_) { |
| + this->RemoveEntryByUrl(entry.URL()); |
| + } |
| +} |