| OLD | NEW |
| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 if (storage_layer_) { | 139 if (storage_layer_) { |
| 140 storage_layer_->SaveEntry(entry); | 140 storage_layer_->SaveEntry(entry); |
| 141 } | 141 } |
| 142 for (auto& observer : observers_) { | 142 for (auto& observer : observers_) { |
| 143 observer.ReadingListDidApplyChanges(this); | 143 observer.ReadingListDidApplyChanges(this); |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 DCHECK(unseen_entry_count_ == 0); | 146 DCHECK(unseen_entry_count_ == 0); |
| 147 } | 147 } |
| 148 | 148 |
| 149 bool ReadingListModelImpl::DeleteAllEntries() { |
| 150 DCHECK(CalledOnValidThread()); |
| 151 if (!loaded()) { |
| 152 return false; |
| 153 } |
| 154 auto scoped_model_batch_updates = BeginBatchUpdates(); |
| 155 for (const auto& url : Keys()) { |
| 156 RemoveEntryByURL(url); |
| 157 } |
| 158 return entries_->empty(); |
| 159 } |
| 160 |
| 149 void ReadingListModelImpl::UpdateEntryStateCountersOnEntryRemoval( | 161 void ReadingListModelImpl::UpdateEntryStateCountersOnEntryRemoval( |
| 150 const ReadingListEntry& entry) { | 162 const ReadingListEntry& entry) { |
| 151 if (!entry.HasBeenSeen()) { | 163 if (!entry.HasBeenSeen()) { |
| 152 unseen_entry_count_--; | 164 unseen_entry_count_--; |
| 153 } | 165 } |
| 154 if (entry.IsRead()) { | 166 if (entry.IsRead()) { |
| 155 read_entry_count_--; | 167 read_entry_count_--; |
| 156 } else { | 168 } else { |
| 157 unread_entry_count_--; | 169 unread_entry_count_--; |
| 158 } | 170 } |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 | 513 |
| 502 syncer::ModelTypeSyncBridge* ReadingListModelImpl::GetModelTypeSyncBridge() { | 514 syncer::ModelTypeSyncBridge* ReadingListModelImpl::GetModelTypeSyncBridge() { |
| 503 if (!storage_layer_) | 515 if (!storage_layer_) |
| 504 return nullptr; | 516 return nullptr; |
| 505 return storage_layer_.get(); | 517 return storage_layer_.get(); |
| 506 } | 518 } |
| 507 | 519 |
| 508 ReadingListModelStorage* ReadingListModelImpl::StorageLayer() { | 520 ReadingListModelStorage* ReadingListModelImpl::StorageLayer() { |
| 509 return storage_layer_.get(); | 521 return storage_layer_.get(); |
| 510 } | 522 } |
| OLD | NEW |