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

Side by Side Diff: components/reading_list/ios/reading_list_model_impl.cc

Issue 2565753002: Only distill unread items (Closed)
Patch Set: past tense in comments 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 unified diff | Download patch
« no previous file with comments | « no previous file | components/reading_list/ios/reading_list_model_observer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/reading_list/ios/reading_list_model_impl.h" 5 #include "components/reading_list/ios/reading_list_model_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 unread_entry_count_--; 163 unread_entry_count_--;
164 } 164 }
165 existing_entry->MergeWithEntry(*entry); 165 existing_entry->MergeWithEntry(*entry);
166 166
167 existing_entry = GetMutableEntryFromURL(url); 167 existing_entry = GetMutableEntryFromURL(url);
168 if (existing_entry->IsRead()) { 168 if (existing_entry->IsRead()) {
169 read_entry_count_++; 169 read_entry_count_++;
170 } else { 170 } else {
171 unread_entry_count_++; 171 unread_entry_count_++;
172 } 172 }
173 for (auto& observer : observers_) 173 for (auto& observer : observers_) {
174 observer.ReadingListDidMoveEntry(this, url);
174 observer.ReadingListDidApplyChanges(this); 175 observer.ReadingListDidApplyChanges(this);
176 }
177
175 return existing_entry; 178 return existing_entry;
176 } 179 }
177 180
178 void ReadingListModelImpl::SyncRemoveEntry(const GURL& url) { 181 void ReadingListModelImpl::SyncRemoveEntry(const GURL& url) {
179 RemoveEntryByURLImpl(url, true); 182 RemoveEntryByURLImpl(url, true);
180 } 183 }
181 184
182 void ReadingListModelImpl::RemoveEntryByURL(const GURL& url) { 185 void ReadingListModelImpl::RemoveEntryByURL(const GURL& url) {
183 RemoveEntryByURLImpl(url, false); 186 RemoveEntryByURLImpl(url, false);
184 } 187 }
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 } else { 259 } else {
257 unread_entry_count_++; 260 unread_entry_count_++;
258 read_entry_count_--; 261 read_entry_count_--;
259 } 262 }
260 entry.SetRead(read); 263 entry.SetRead(read);
261 entry.MarkEntryUpdated(); 264 entry.MarkEntryUpdated();
262 if (storage_layer_) { 265 if (storage_layer_) {
263 storage_layer_->SaveEntry(entry); 266 storage_layer_->SaveEntry(entry);
264 } 267 }
265 for (ReadingListModelObserver& observer : observers_) { 268 for (ReadingListModelObserver& observer : observers_) {
269 observer.ReadingListDidMoveEntry(this, url);
266 observer.ReadingListDidApplyChanges(this); 270 observer.ReadingListDidApplyChanges(this);
267 } 271 }
268 } 272 }
269 273
270 void ReadingListModelImpl::SetEntryTitle(const GURL& url, 274 void ReadingListModelImpl::SetEntryTitle(const GURL& url,
271 const std::string& title) { 275 const std::string& title) {
272 DCHECK(CalledOnValidThread()); 276 DCHECK(CalledOnValidThread());
273 DCHECK(loaded()); 277 DCHECK(loaded());
274 auto iterator = entries_->find(url); 278 auto iterator = entries_->find(url);
275 if (iterator == entries_->end()) { 279 if (iterator == entries_->end()) {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 syncer::ModelTypeSyncBridge* ReadingListModelImpl::GetModelTypeSyncBridge() { 403 syncer::ModelTypeSyncBridge* ReadingListModelImpl::GetModelTypeSyncBridge() {
400 DCHECK(loaded()); 404 DCHECK(loaded());
401 if (!storage_layer_) 405 if (!storage_layer_)
402 return nullptr; 406 return nullptr;
403 return storage_layer_->GetModelTypeSyncBridge(); 407 return storage_layer_->GetModelTypeSyncBridge();
404 } 408 }
405 409
406 ReadingListModelStorage* ReadingListModelImpl::StorageLayer() { 410 ReadingListModelStorage* ReadingListModelImpl::StorageLayer() {
407 return storage_layer_.get(); 411 return storage_layer_.get();
408 } 412 }
OLDNEW
« no previous file with comments | « no previous file | components/reading_list/ios/reading_list_model_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698