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/core/reading_list_store.h" | 5 #include "components/reading_list/core/reading_list_store.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "components/sync/protocol/model_type_state.pb.h" | 22 #include "components/sync/protocol/model_type_state.pb.h" |
23 | 23 |
24 ReadingListStore::ReadingListStore( | 24 ReadingListStore::ReadingListStore( |
25 StoreFactoryFunction create_store_callback, | 25 StoreFactoryFunction create_store_callback, |
26 const ChangeProcessorFactory& change_processor_factory) | 26 const ChangeProcessorFactory& change_processor_factory) |
27 : ReadingListModelStorage(change_processor_factory, syncer::READING_LIST), | 27 : ReadingListModelStorage(change_processor_factory, syncer::READING_LIST), |
28 create_store_callback_(create_store_callback), | 28 create_store_callback_(create_store_callback), |
29 pending_transaction_count_(0) {} | 29 pending_transaction_count_(0) {} |
30 | 30 |
31 ReadingListStore::~ReadingListStore() { | 31 ReadingListStore::~ReadingListStore() { |
| 32 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
32 DCHECK_EQ(0, pending_transaction_count_); | 33 DCHECK_EQ(0, pending_transaction_count_); |
33 } | 34 } |
34 | 35 |
35 void ReadingListStore::SetReadingListModel(ReadingListModel* model, | 36 void ReadingListStore::SetReadingListModel(ReadingListModel* model, |
36 ReadingListStoreDelegate* delegate, | 37 ReadingListStoreDelegate* delegate, |
37 base::Clock* clock) { | 38 base::Clock* clock) { |
38 DCHECK(CalledOnValidThread()); | 39 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
39 model_ = model; | 40 model_ = model; |
40 delegate_ = delegate; | 41 delegate_ = delegate; |
41 clock_ = clock; | 42 clock_ = clock; |
42 create_store_callback_.Run( | 43 create_store_callback_.Run( |
43 base::Bind(&ReadingListStore::OnStoreCreated, base::AsWeakPtr(this))); | 44 base::Bind(&ReadingListStore::OnStoreCreated, base::AsWeakPtr(this))); |
44 } | 45 } |
45 | 46 |
46 std::unique_ptr<ReadingListModelStorage::ScopedBatchUpdate> | 47 std::unique_ptr<ReadingListModelStorage::ScopedBatchUpdate> |
47 ReadingListStore::EnsureBatchCreated() { | 48 ReadingListStore::EnsureBatchCreated() { |
48 return base::WrapUnique<ReadingListModelStorage::ScopedBatchUpdate>( | 49 return base::WrapUnique<ReadingListModelStorage::ScopedBatchUpdate>( |
49 new ScopedBatchUpdate(this)); | 50 new ScopedBatchUpdate(this)); |
50 } | 51 } |
51 | 52 |
52 ReadingListStore::ScopedBatchUpdate::ScopedBatchUpdate(ReadingListStore* store) | 53 ReadingListStore::ScopedBatchUpdate::ScopedBatchUpdate(ReadingListStore* store) |
53 : store_(store) { | 54 : store_(store) { |
54 store_->BeginTransaction(); | 55 store_->BeginTransaction(); |
55 } | 56 } |
56 | 57 |
57 ReadingListStore::ScopedBatchUpdate::~ScopedBatchUpdate() { | 58 ReadingListStore::ScopedBatchUpdate::~ScopedBatchUpdate() { |
58 store_->CommitTransaction(); | 59 store_->CommitTransaction(); |
59 } | 60 } |
60 | 61 |
61 void ReadingListStore::BeginTransaction() { | 62 void ReadingListStore::BeginTransaction() { |
62 DCHECK(CalledOnValidThread()); | 63 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
63 pending_transaction_count_++; | 64 pending_transaction_count_++; |
64 if (pending_transaction_count_ == 1) { | 65 if (pending_transaction_count_ == 1) { |
65 batch_ = store_->CreateWriteBatch(); | 66 batch_ = store_->CreateWriteBatch(); |
66 } | 67 } |
67 } | 68 } |
68 | 69 |
69 void ReadingListStore::CommitTransaction() { | 70 void ReadingListStore::CommitTransaction() { |
70 DCHECK(CalledOnValidThread()); | 71 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
71 pending_transaction_count_--; | 72 pending_transaction_count_--; |
72 if (pending_transaction_count_ == 0) { | 73 if (pending_transaction_count_ == 0) { |
73 store_->CommitWriteBatch( | 74 store_->CommitWriteBatch( |
74 std::move(batch_), | 75 std::move(batch_), |
75 base::Bind(&ReadingListStore::OnDatabaseSave, base::AsWeakPtr(this))); | 76 base::Bind(&ReadingListStore::OnDatabaseSave, base::AsWeakPtr(this))); |
76 batch_.reset(); | 77 batch_.reset(); |
77 } | 78 } |
78 } | 79 } |
79 | 80 |
80 void ReadingListStore::SaveEntry(const ReadingListEntry& entry) { | 81 void ReadingListStore::SaveEntry(const ReadingListEntry& entry) { |
81 DCHECK(CalledOnValidThread()); | 82 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
82 auto token = EnsureBatchCreated(); | 83 auto token = EnsureBatchCreated(); |
83 | 84 |
84 std::unique_ptr<reading_list::ReadingListLocal> pb_entry = | 85 std::unique_ptr<reading_list::ReadingListLocal> pb_entry = |
85 entry.AsReadingListLocal(clock_->Now()); | 86 entry.AsReadingListLocal(clock_->Now()); |
86 | 87 |
87 batch_->WriteData(entry.URL().spec(), pb_entry->SerializeAsString()); | 88 batch_->WriteData(entry.URL().spec(), pb_entry->SerializeAsString()); |
88 | 89 |
89 if (!change_processor()->IsTrackingMetadata()) { | 90 if (!change_processor()->IsTrackingMetadata()) { |
90 return; | 91 return; |
91 } | 92 } |
92 std::unique_ptr<sync_pb::ReadingListSpecifics> pb_entry_sync = | 93 std::unique_ptr<sync_pb::ReadingListSpecifics> pb_entry_sync = |
93 entry.AsReadingListSpecifics(); | 94 entry.AsReadingListSpecifics(); |
94 | 95 |
95 std::unique_ptr<syncer::MetadataChangeList> metadata_change_list = | 96 std::unique_ptr<syncer::MetadataChangeList> metadata_change_list = |
96 CreateMetadataChangeList(); | 97 CreateMetadataChangeList(); |
97 | 98 |
98 std::unique_ptr<syncer::EntityData> entity_data(new syncer::EntityData()); | 99 std::unique_ptr<syncer::EntityData> entity_data(new syncer::EntityData()); |
99 *entity_data->specifics.mutable_reading_list() = *pb_entry_sync; | 100 *entity_data->specifics.mutable_reading_list() = *pb_entry_sync; |
100 entity_data->non_unique_name = pb_entry_sync->entry_id(); | 101 entity_data->non_unique_name = pb_entry_sync->entry_id(); |
101 | 102 |
102 change_processor()->Put(entry.URL().spec(), std::move(entity_data), | 103 change_processor()->Put(entry.URL().spec(), std::move(entity_data), |
103 metadata_change_list.get()); | 104 metadata_change_list.get()); |
104 batch_->TransferMetadataChanges(std::move(metadata_change_list)); | 105 batch_->TransferMetadataChanges(std::move(metadata_change_list)); |
105 } | 106 } |
106 | 107 |
107 void ReadingListStore::RemoveEntry(const ReadingListEntry& entry) { | 108 void ReadingListStore::RemoveEntry(const ReadingListEntry& entry) { |
108 DCHECK(CalledOnValidThread()); | 109 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
109 auto token = EnsureBatchCreated(); | 110 auto token = EnsureBatchCreated(); |
110 | 111 |
111 batch_->DeleteData(entry.URL().spec()); | 112 batch_->DeleteData(entry.URL().spec()); |
112 if (!change_processor()->IsTrackingMetadata()) { | 113 if (!change_processor()->IsTrackingMetadata()) { |
113 return; | 114 return; |
114 } | 115 } |
115 std::unique_ptr<syncer::MetadataChangeList> metadata_change_list = | 116 std::unique_ptr<syncer::MetadataChangeList> metadata_change_list = |
116 CreateMetadataChangeList(); | 117 CreateMetadataChangeList(); |
117 | 118 |
118 change_processor()->Delete(entry.URL().spec(), metadata_change_list.get()); | 119 change_processor()->Delete(entry.URL().spec(), metadata_change_list.get()); |
119 batch_->TransferMetadataChanges(std::move(metadata_change_list)); | 120 batch_->TransferMetadataChanges(std::move(metadata_change_list)); |
120 } | 121 } |
121 | 122 |
122 void ReadingListStore::OnDatabaseLoad( | 123 void ReadingListStore::OnDatabaseLoad( |
123 syncer::ModelTypeStore::Result result, | 124 syncer::ModelTypeStore::Result result, |
124 std::unique_ptr<syncer::ModelTypeStore::RecordList> entries) { | 125 std::unique_ptr<syncer::ModelTypeStore::RecordList> entries) { |
125 DCHECK(CalledOnValidThread()); | 126 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
126 if (result != syncer::ModelTypeStore::Result::SUCCESS) { | 127 if (result != syncer::ModelTypeStore::Result::SUCCESS) { |
127 change_processor()->ReportError(FROM_HERE, | 128 change_processor()->ReportError(FROM_HERE, |
128 "Cannot load Reading List Database."); | 129 "Cannot load Reading List Database."); |
129 return; | 130 return; |
130 } | 131 } |
131 auto loaded_entries = | 132 auto loaded_entries = |
132 base::MakeUnique<ReadingListStoreDelegate::ReadingListEntries>(); | 133 base::MakeUnique<ReadingListStoreDelegate::ReadingListEntries>(); |
133 | 134 |
134 for (const syncer::ModelTypeStore::Record& r : *entries.get()) { | 135 for (const syncer::ModelTypeStore::Record& r : *entries.get()) { |
135 reading_list::ReadingListLocal proto; | 136 reading_list::ReadingListLocal proto; |
(...skipping 15 matching lines...) Expand all Loading... |
151 | 152 |
152 delegate_->StoreLoaded(std::move(loaded_entries)); | 153 delegate_->StoreLoaded(std::move(loaded_entries)); |
153 | 154 |
154 store_->ReadAllMetadata( | 155 store_->ReadAllMetadata( |
155 base::Bind(&ReadingListStore::OnReadAllMetadata, base::AsWeakPtr(this))); | 156 base::Bind(&ReadingListStore::OnReadAllMetadata, base::AsWeakPtr(this))); |
156 } | 157 } |
157 | 158 |
158 void ReadingListStore::OnReadAllMetadata( | 159 void ReadingListStore::OnReadAllMetadata( |
159 base::Optional<syncer::ModelError> error, | 160 base::Optional<syncer::ModelError> error, |
160 std::unique_ptr<syncer::MetadataBatch> metadata_batch) { | 161 std::unique_ptr<syncer::MetadataBatch> metadata_batch) { |
161 DCHECK(CalledOnValidThread()); | 162 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
162 if (error) { | 163 if (error) { |
163 change_processor()->ReportError(FROM_HERE, "Failed to read metadata."); | 164 change_processor()->ReportError(FROM_HERE, "Failed to read metadata."); |
164 } else { | 165 } else { |
165 change_processor()->ModelReadyToSync(std::move(metadata_batch)); | 166 change_processor()->ModelReadyToSync(std::move(metadata_batch)); |
166 } | 167 } |
167 } | 168 } |
168 | 169 |
169 void ReadingListStore::OnDatabaseSave(syncer::ModelTypeStore::Result result) { | 170 void ReadingListStore::OnDatabaseSave(syncer::ModelTypeStore::Result result) { |
170 return; | 171 return; |
171 } | 172 } |
172 | 173 |
173 void ReadingListStore::OnStoreCreated( | 174 void ReadingListStore::OnStoreCreated( |
174 syncer::ModelTypeStore::Result result, | 175 syncer::ModelTypeStore::Result result, |
175 std::unique_ptr<syncer::ModelTypeStore> store) { | 176 std::unique_ptr<syncer::ModelTypeStore> store) { |
176 DCHECK(CalledOnValidThread()); | 177 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
177 if (result != syncer::ModelTypeStore::Result::SUCCESS) { | 178 if (result != syncer::ModelTypeStore::Result::SUCCESS) { |
178 // TODO(crbug.com/664926): handle store creation error. | 179 // TODO(crbug.com/664926): handle store creation error. |
179 return; | 180 return; |
180 } | 181 } |
181 store_ = std::move(store); | 182 store_ = std::move(store); |
182 store_->ReadAllData( | 183 store_->ReadAllData( |
183 base::Bind(&ReadingListStore::OnDatabaseLoad, base::AsWeakPtr(this))); | 184 base::Bind(&ReadingListStore::OnDatabaseLoad, base::AsWeakPtr(this))); |
184 return; | 185 return; |
185 } | 186 } |
186 | 187 |
(...skipping 13 matching lines...) Expand all Loading... |
200 // not present in sync should immediately be Put(...) to the processor before | 201 // not present in sync should immediately be Put(...) to the processor before |
201 // returning. The same MetadataChangeList that was passed into this function | 202 // returning. The same MetadataChangeList that was passed into this function |
202 // can be passed to Put(...) calls. Delete(...) can also be called but should | 203 // can be passed to Put(...) calls. Delete(...) can also be called but should |
203 // not be needed for most model types. Durable storage writes, if not able to | 204 // not be needed for most model types. Durable storage writes, if not able to |
204 // combine all change atomically, should save the metadata after the data | 205 // combine all change atomically, should save the metadata after the data |
205 // changes, so that this merge will be re-driven by sync if is not completely | 206 // changes, so that this merge will be re-driven by sync if is not completely |
206 // saved during the current run. | 207 // saved during the current run. |
207 base::Optional<syncer::ModelError> ReadingListStore::MergeSyncData( | 208 base::Optional<syncer::ModelError> ReadingListStore::MergeSyncData( |
208 std::unique_ptr<syncer::MetadataChangeList> metadata_change_list, | 209 std::unique_ptr<syncer::MetadataChangeList> metadata_change_list, |
209 syncer::EntityDataMap entity_data_map) { | 210 syncer::EntityDataMap entity_data_map) { |
210 DCHECK(CalledOnValidThread()); | 211 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
211 auto token = EnsureBatchCreated(); | 212 auto token = EnsureBatchCreated(); |
212 // Keep track of the last update of each item. | 213 // Keep track of the last update of each item. |
213 std::set<std::string> synced_entries; | 214 std::set<std::string> synced_entries; |
214 std::unique_ptr<ReadingListModel::ScopedReadingListBatchUpdate> | 215 std::unique_ptr<ReadingListModel::ScopedReadingListBatchUpdate> |
215 model_batch_updates = model_->BeginBatchUpdates(); | 216 model_batch_updates = model_->BeginBatchUpdates(); |
216 | 217 |
217 // Merge sync to local data. | 218 // Merge sync to local data. |
218 for (const auto& kv : entity_data_map) { | 219 for (const auto& kv : entity_data_map) { |
219 synced_entries.insert(kv.first); | 220 synced_entries.insert(kv.first); |
220 const sync_pb::ReadingListSpecifics& specifics = | 221 const sync_pb::ReadingListSpecifics& specifics = |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 } | 287 } |
287 | 288 |
288 // Apply changes from the sync server locally. | 289 // Apply changes from the sync server locally. |
289 // Please note that |entity_changes| might have fewer entries than | 290 // Please note that |entity_changes| might have fewer entries than |
290 // |metadata_change_list| in case when some of the data changes are filtered | 291 // |metadata_change_list| in case when some of the data changes are filtered |
291 // out, or even be empty in case when a commit confirmation is processed and | 292 // out, or even be empty in case when a commit confirmation is processed and |
292 // only the metadata needs to persisted. | 293 // only the metadata needs to persisted. |
293 base::Optional<syncer::ModelError> ReadingListStore::ApplySyncChanges( | 294 base::Optional<syncer::ModelError> ReadingListStore::ApplySyncChanges( |
294 std::unique_ptr<syncer::MetadataChangeList> metadata_change_list, | 295 std::unique_ptr<syncer::MetadataChangeList> metadata_change_list, |
295 syncer::EntityChangeList entity_changes) { | 296 syncer::EntityChangeList entity_changes) { |
296 DCHECK(CalledOnValidThread()); | 297 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
297 std::unique_ptr<ReadingListModel::ScopedReadingListBatchUpdate> batch = | 298 std::unique_ptr<ReadingListModel::ScopedReadingListBatchUpdate> batch = |
298 model_->BeginBatchUpdates(); | 299 model_->BeginBatchUpdates(); |
299 auto token = EnsureBatchCreated(); | 300 auto token = EnsureBatchCreated(); |
300 | 301 |
301 for (syncer::EntityChange& change : entity_changes) { | 302 for (syncer::EntityChange& change : entity_changes) { |
302 if (change.type() == syncer::EntityChange::ACTION_DELETE) { | 303 if (change.type() == syncer::EntityChange::ACTION_DELETE) { |
303 batch_->DeleteData(change.storage_key()); | 304 batch_->DeleteData(change.storage_key()); |
304 // Need to notify model that entry is deleted. | 305 // Need to notify model that entry is deleted. |
305 delegate_->SyncRemoveEntry(GURL(change.storage_key())); | 306 delegate_->SyncRemoveEntry(GURL(change.storage_key())); |
306 } else { | 307 } else { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 } | 350 } |
350 } | 351 } |
351 } | 352 } |
352 | 353 |
353 batch_->TransferMetadataChanges(std::move(metadata_change_list)); | 354 batch_->TransferMetadataChanges(std::move(metadata_change_list)); |
354 return {}; | 355 return {}; |
355 } | 356 } |
356 | 357 |
357 void ReadingListStore::GetData(StorageKeyList storage_keys, | 358 void ReadingListStore::GetData(StorageKeyList storage_keys, |
358 DataCallback callback) { | 359 DataCallback callback) { |
359 DCHECK(CalledOnValidThread()); | 360 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
360 auto batch = base::MakeUnique<syncer::MutableDataBatch>(); | 361 auto batch = base::MakeUnique<syncer::MutableDataBatch>(); |
361 for (const std::string& url_string : storage_keys) { | 362 for (const std::string& url_string : storage_keys) { |
362 const ReadingListEntry* entry = model_->GetEntryByURL(GURL(url_string)); | 363 const ReadingListEntry* entry = model_->GetEntryByURL(GURL(url_string)); |
363 if (entry) { | 364 if (entry) { |
364 AddEntryToBatch(batch.get(), *entry); | 365 AddEntryToBatch(batch.get(), *entry); |
365 } | 366 } |
366 } | 367 } |
367 | 368 |
368 callback.Run(std::move(batch)); | 369 callback.Run(std::move(batch)); |
369 } | 370 } |
370 | 371 |
371 void ReadingListStore::GetAllData(DataCallback callback) { | 372 void ReadingListStore::GetAllData(DataCallback callback) { |
372 DCHECK(CalledOnValidThread()); | 373 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
373 auto batch = base::MakeUnique<syncer::MutableDataBatch>(); | 374 auto batch = base::MakeUnique<syncer::MutableDataBatch>(); |
374 | 375 |
375 for (const auto& url : model_->Keys()) { | 376 for (const auto& url : model_->Keys()) { |
376 const ReadingListEntry* entry = model_->GetEntryByURL(GURL(url)); | 377 const ReadingListEntry* entry = model_->GetEntryByURL(GURL(url)); |
377 AddEntryToBatch(batch.get(), *entry); | 378 AddEntryToBatch(batch.get(), *entry); |
378 } | 379 } |
379 | 380 |
380 callback.Run(std::move(batch)); | 381 callback.Run(std::move(batch)); |
381 } | 382 } |
382 | 383 |
383 void ReadingListStore::AddEntryToBatch(syncer::MutableDataBatch* batch, | 384 void ReadingListStore::AddEntryToBatch(syncer::MutableDataBatch* batch, |
384 const ReadingListEntry& entry) { | 385 const ReadingListEntry& entry) { |
385 DCHECK(CalledOnValidThread()); | 386 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
386 std::unique_ptr<sync_pb::ReadingListSpecifics> entry_pb = | 387 std::unique_ptr<sync_pb::ReadingListSpecifics> entry_pb = |
387 entry.AsReadingListSpecifics(); | 388 entry.AsReadingListSpecifics(); |
388 | 389 |
389 std::unique_ptr<syncer::EntityData> entity_data(new syncer::EntityData()); | 390 std::unique_ptr<syncer::EntityData> entity_data(new syncer::EntityData()); |
390 *(entity_data->specifics.mutable_reading_list()) = *entry_pb; | 391 *(entity_data->specifics.mutable_reading_list()) = *entry_pb; |
391 entity_data->non_unique_name = entry_pb->entry_id(); | 392 entity_data->non_unique_name = entry_pb->entry_id(); |
392 | 393 |
393 batch->Put(entry_pb->entry_id(), std::move(entity_data)); | 394 batch->Put(entry_pb->entry_id(), std::move(entity_data)); |
394 } | 395 } |
395 | 396 |
396 // Get or generate a client tag for |entity_data|. This must be the same tag | 397 // Get or generate a client tag for |entity_data|. This must be the same tag |
397 // that was/would have been generated in the SyncableService/Directory world | 398 // that was/would have been generated in the SyncableService/Directory world |
398 // for backward compatibility with pre-USS clients. The only time this | 399 // for backward compatibility with pre-USS clients. The only time this |
399 // theoretically needs to be called is on the creation of local data, however | 400 // theoretically needs to be called is on the creation of local data, however |
400 // it is also used to verify the hash of remote data. If a data type was never | 401 // it is also used to verify the hash of remote data. If a data type was never |
401 // launched pre-USS, then method does not need to be different from | 402 // launched pre-USS, then method does not need to be different from |
402 // GetStorageKey(). | 403 // GetStorageKey(). |
403 std::string ReadingListStore::GetClientTag( | 404 std::string ReadingListStore::GetClientTag( |
404 const syncer::EntityData& entity_data) { | 405 const syncer::EntityData& entity_data) { |
405 DCHECK(CalledOnValidThread()); | 406 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
406 return GetStorageKey(entity_data); | 407 return GetStorageKey(entity_data); |
407 } | 408 } |
408 | 409 |
409 // Get or generate a storage key for |entity_data|. This will only ever be | 410 // Get or generate a storage key for |entity_data|. This will only ever be |
410 // called once when first encountering a remote entity. Local changes will | 411 // called once when first encountering a remote entity. Local changes will |
411 // provide their storage keys directly to Put instead of using this method. | 412 // provide their storage keys directly to Put instead of using this method. |
412 // Theoretically this function doesn't need to be stable across multiple calls | 413 // Theoretically this function doesn't need to be stable across multiple calls |
413 // on the same or different clients, but to keep things simple, it probably | 414 // on the same or different clients, but to keep things simple, it probably |
414 // should be. | 415 // should be. |
415 std::string ReadingListStore::GetStorageKey( | 416 std::string ReadingListStore::GetStorageKey( |
416 const syncer::EntityData& entity_data) { | 417 const syncer::EntityData& entity_data) { |
417 DCHECK(CalledOnValidThread()); | 418 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
418 return entity_data.specifics.reading_list().entry_id(); | 419 return entity_data.specifics.reading_list().entry_id(); |
419 } | 420 } |
420 | 421 |
421 bool ReadingListStore::CompareEntriesForSync( | 422 bool ReadingListStore::CompareEntriesForSync( |
422 const sync_pb::ReadingListSpecifics& lhs, | 423 const sync_pb::ReadingListSpecifics& lhs, |
423 const sync_pb::ReadingListSpecifics& rhs) { | 424 const sync_pb::ReadingListSpecifics& rhs) { |
424 DCHECK(lhs.entry_id() == rhs.entry_id()); | 425 DCHECK(lhs.entry_id() == rhs.entry_id()); |
425 DCHECK(lhs.has_update_time_us()); | 426 DCHECK(lhs.has_update_time_us()); |
426 DCHECK(rhs.has_update_time_us()); | 427 DCHECK(rhs.has_update_time_us()); |
427 DCHECK(lhs.has_update_title_time_us()); | 428 DCHECK(lhs.has_update_title_time_us()); |
(...skipping 27 matching lines...) Expand all Loading... |
455 if (rhs.first_read_time_us() == 0 && lhs.first_read_time_us() != 0) { | 456 if (rhs.first_read_time_us() == 0 && lhs.first_read_time_us() != 0) { |
456 return false; | 457 return false; |
457 } | 458 } |
458 if (rhs.first_read_time_us() > lhs.first_read_time_us() && | 459 if (rhs.first_read_time_us() > lhs.first_read_time_us() && |
459 lhs.first_read_time_us() != 0) { | 460 lhs.first_read_time_us() != 0) { |
460 return false; | 461 return false; |
461 } | 462 } |
462 } | 463 } |
463 return true; | 464 return true; |
464 } | 465 } |
OLD | NEW |