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

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

Issue 2553143002: Create a strict order in ReadingListSpecifics (Closed)
Patch Set: for review 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()); 155 // DCHECK(existing_entry->UpdateTime() < entry->UpdateTime());
gambard 2016/12/06 17:02:22 Remove it?
Olivier 2016/12/06 17:16:21 Done.
156 156
157 GURL url = entry->URL(); 157 GURL url = entry->URL();
158 158
159 for (auto& observer : observers_) 159 for (auto& observer : observers_)
160 observer.ReadingListWillMoveEntry(this, url); 160 observer.ReadingListWillMoveEntry(this, url);
161 161
162 if (existing_entry->IsRead()) { 162 if (existing_entry->IsRead()) {
163 read_entry_count_--; 163 read_entry_count_--;
164 } else { 164 } else {
165 unread_entry_count_--; 165 unread_entry_count_--;
166 } 166 }
167 // Merge local data in new entry. 167 existing_entry->MergeWithEntry(*entry);
168 entry->MergeLocalStateFrom(*existing_entry);
169
170 entries_->find(url)->second = std::move(*entry);
171 168
172 existing_entry = GetMutableEntryFromURL(url); 169 existing_entry = GetMutableEntryFromURL(url);
173 if (existing_entry->IsRead()) { 170 if (existing_entry->IsRead()) {
174 read_entry_count_++; 171 read_entry_count_++;
175 } else { 172 } else {
176 unread_entry_count_++; 173 unread_entry_count_++;
177 } 174 }
178 for (auto& observer : observers_) 175 for (auto& observer : observers_)
179 observer.ReadingListDidApplyChanges(this); 176 observer.ReadingListDidApplyChanges(this);
180 return existing_entry; 177 return existing_entry;
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 syncer::ModelTypeSyncBridge* ReadingListModelImpl::GetModelTypeSyncBridge() { 401 syncer::ModelTypeSyncBridge* ReadingListModelImpl::GetModelTypeSyncBridge() {
405 DCHECK(loaded()); 402 DCHECK(loaded());
406 if (!storage_layer_) 403 if (!storage_layer_)
407 return nullptr; 404 return nullptr;
408 return storage_layer_->GetModelTypeSyncBridge(); 405 return storage_layer_->GetModelTypeSyncBridge();
409 } 406 }
410 407
411 ReadingListModelStorage* ReadingListModelImpl::StorageLayer() { 408 ReadingListModelStorage* ReadingListModelImpl::StorageLayer() {
412 return storage_layer_.get(); 409 return storage_layer_.get();
413 } 410 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698