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_store.h" | 5 #include "components/reading_list/ios/reading_list_store.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 "components/reading_list/ios/proto/reading_list.pb.h" | 10 #include "components/reading_list/ios/proto/reading_list.pb.h" |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 // Notify model about updated entry. | 228 // Notify model about updated entry. |
229 delegate_->SyncAddEntry(std::move(entry)); | 229 delegate_->SyncAddEntry(std::move(entry)); |
230 } else { | 230 } else { |
231 // Merge the local data and the sync data and store the result. | 231 // Merge the local data and the sync data and store the result. |
232 ReadingListEntry* merged_entry = | 232 ReadingListEntry* merged_entry = |
233 delegate_->SyncMergeEntry(std::move(entry)); | 233 delegate_->SyncMergeEntry(std::move(entry)); |
234 | 234 |
235 // Write to the store. | 235 // Write to the store. |
236 std::unique_ptr<reading_list::ReadingListLocal> entry_local_pb = | 236 std::unique_ptr<reading_list::ReadingListLocal> entry_local_pb = |
237 merged_entry->AsReadingListLocal(); | 237 merged_entry->AsReadingListLocal(); |
238 batch_->WriteData(entry->URL().spec(), | 238 batch_->WriteData(merged_entry->URL().spec(), |
239 entry_local_pb->SerializeAsString()); | 239 entry_local_pb->SerializeAsString()); |
240 | 240 |
241 // Send to sync | 241 // Send to sync |
242 std::unique_ptr<sync_pb::ReadingListSpecifics> entry_sync_pb = | 242 std::unique_ptr<sync_pb::ReadingListSpecifics> entry_sync_pb = |
243 merged_entry->AsReadingListSpecifics(); | 243 merged_entry->AsReadingListSpecifics(); |
244 DCHECK(CompareEntriesForSync(specifics, *entry_sync_pb)); | 244 DCHECK(CompareEntriesForSync(specifics, *entry_sync_pb)); |
245 auto entity_data = base::MakeUnique<syncer::EntityData>(); | 245 auto entity_data = base::MakeUnique<syncer::EntityData>(); |
246 *(entity_data->specifics.mutable_reading_list()) = *entry_sync_pb; | 246 *(entity_data->specifics.mutable_reading_list()) = *entry_sync_pb; |
247 entity_data->non_unique_name = entry_sync_pb->entry_id(); | 247 entity_data->non_unique_name = entry_sync_pb->entry_id(); |
248 | 248 |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 if (rhs.first_read_time_us() == 0 && lhs.first_read_time_us() != 0) { | 442 if (rhs.first_read_time_us() == 0 && lhs.first_read_time_us() != 0) { |
443 return false; | 443 return false; |
444 } | 444 } |
445 if (rhs.first_read_time_us() > lhs.first_read_time_us() && | 445 if (rhs.first_read_time_us() > lhs.first_read_time_us() && |
446 lhs.first_read_time_us() != 0) { | 446 lhs.first_read_time_us() != 0) { |
447 return false; | 447 return false; |
448 } | 448 } |
449 } | 449 } |
450 return true; | 450 return true; |
451 } | 451 } |
OLD | NEW |