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