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

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

Issue 2553143002: Create a strict order in ReadingListSpecifics (Closed)
Patch Set: rebase 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
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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 observer.ReadingListDidApplyChanges(this); 145 observer.ReadingListDidApplyChanges(this);
146 } 146 }
147 } 147 }
148 148
149 ReadingListEntry* ReadingListModelImpl::SyncMergeEntry( 149 ReadingListEntry* ReadingListModelImpl::SyncMergeEntry(
150 std::unique_ptr<ReadingListEntry> entry) { 150 std::unique_ptr<ReadingListEntry> entry) {
151 DCHECK(CalledOnValidThread()); 151 DCHECK(CalledOnValidThread());
152 DCHECK(loaded()); 152 DCHECK(loaded());
153 ReadingListEntry* existing_entry = GetMutableEntryFromURL(entry->URL()); 153 ReadingListEntry* existing_entry = GetMutableEntryFromURL(entry->URL());
154 DCHECK(existing_entry); 154 DCHECK(existing_entry);
155 DCHECK(existing_entry->UpdateTime() < entry->UpdateTime());
156
157 GURL url = entry->URL(); 155 GURL url = entry->URL();
158 156
159 for (auto& observer : observers_) 157 for (auto& observer : observers_)
160 observer.ReadingListWillMoveEntry(this, url); 158 observer.ReadingListWillMoveEntry(this, url);
161 159
162 if (existing_entry->IsRead()) { 160 if (existing_entry->IsRead()) {
163 read_entry_count_--; 161 read_entry_count_--;
164 } else { 162 } else {
165 unread_entry_count_--; 163 unread_entry_count_--;
166 } 164 }
167 // Merge local data in new entry. 165 existing_entry->MergeWithEntry(*entry);
168 entry->MergeLocalStateFrom(*existing_entry);
169
170 entries_->find(url)->second = std::move(*entry);
171 166
172 existing_entry = GetMutableEntryFromURL(url); 167 existing_entry = GetMutableEntryFromURL(url);
173 if (existing_entry->IsRead()) { 168 if (existing_entry->IsRead()) {
174 read_entry_count_++; 169 read_entry_count_++;
175 } else { 170 } else {
176 unread_entry_count_++; 171 unread_entry_count_++;
177 } 172 }
178 for (auto& observer : observers_) 173 for (auto& observer : observers_)
179 observer.ReadingListDidApplyChanges(this); 174 observer.ReadingListDidApplyChanges(this);
180 return existing_entry; 175 return existing_entry;
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 syncer::ModelTypeSyncBridge* ReadingListModelImpl::GetModelTypeSyncBridge() { 399 syncer::ModelTypeSyncBridge* ReadingListModelImpl::GetModelTypeSyncBridge() {
405 DCHECK(loaded()); 400 DCHECK(loaded());
406 if (!storage_layer_) 401 if (!storage_layer_)
407 return nullptr; 402 return nullptr;
408 return storage_layer_->GetModelTypeSyncBridge(); 403 return storage_layer_->GetModelTypeSyncBridge();
409 } 404 }
410 405
411 ReadingListModelStorage* ReadingListModelImpl::StorageLayer() { 406 ReadingListModelStorage* ReadingListModelImpl::StorageLayer() {
412 return storage_layer_.get(); 407 return storage_layer_.get();
413 } 408 }
OLDNEW
« no previous file with comments | « components/reading_list/ios/reading_list_entry_unittest.cc ('k') | components/reading_list/ios/reading_list_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698