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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 DCHECK(CalledOnValidThread()); | 411 DCHECK(CalledOnValidThread()); |
412 return entity_data.specifics.reading_list().entry_id(); | 412 return entity_data.specifics.reading_list().entry_id(); |
413 } | 413 } |
414 | 414 |
415 bool ReadingListStore::CompareEntriesForSync( | 415 bool ReadingListStore::CompareEntriesForSync( |
416 const sync_pb::ReadingListSpecifics& lhs, | 416 const sync_pb::ReadingListSpecifics& lhs, |
417 const sync_pb::ReadingListSpecifics& rhs) { | 417 const sync_pb::ReadingListSpecifics& rhs) { |
418 DCHECK(lhs.entry_id() == rhs.entry_id()); | 418 DCHECK(lhs.entry_id() == rhs.entry_id()); |
419 DCHECK(lhs.has_update_time_us()); | 419 DCHECK(lhs.has_update_time_us()); |
420 DCHECK(rhs.has_update_time_us()); | 420 DCHECK(rhs.has_update_time_us()); |
| 421 DCHECK(lhs.has_update_title_time_us()); |
| 422 DCHECK(rhs.has_update_title_time_us()); |
421 DCHECK(lhs.has_creation_time_us()); | 423 DCHECK(lhs.has_creation_time_us()); |
422 DCHECK(rhs.has_creation_time_us()); | 424 DCHECK(rhs.has_creation_time_us()); |
423 DCHECK(lhs.has_url()); | 425 DCHECK(lhs.has_url()); |
424 DCHECK(rhs.has_url()); | 426 DCHECK(rhs.has_url()); |
425 DCHECK(lhs.has_title()); | 427 DCHECK(lhs.has_title()); |
426 DCHECK(rhs.has_title()); | 428 DCHECK(rhs.has_title()); |
427 DCHECK(lhs.has_status()); | 429 DCHECK(lhs.has_status()); |
428 DCHECK(rhs.has_status()); | 430 DCHECK(rhs.has_status()); |
429 if (rhs.url() != lhs.url() || rhs.title().compare(lhs.title()) < 0 || | 431 if (rhs.url() != lhs.url() || |
| 432 rhs.update_title_time_us() < lhs.update_title_time_us() || |
430 rhs.creation_time_us() < lhs.creation_time_us() || | 433 rhs.creation_time_us() < lhs.creation_time_us() || |
431 rhs.update_time_us() < lhs.update_time_us()) { | 434 rhs.update_time_us() < lhs.update_time_us()) { |
432 return false; | 435 return false; |
433 } | 436 } |
434 if (rhs.update_time_us() == lhs.update_time_us()) { | 437 if (rhs.update_time_us() == lhs.update_time_us()) { |
435 if ((rhs.status() == sync_pb::ReadingListSpecifics::UNSEEN && | 438 if ((rhs.status() == sync_pb::ReadingListSpecifics::UNSEEN && |
436 lhs.status() != sync_pb::ReadingListSpecifics::UNSEEN) || | 439 lhs.status() != sync_pb::ReadingListSpecifics::UNSEEN) || |
437 (rhs.status() == sync_pb::ReadingListSpecifics::UNREAD && | 440 (rhs.status() == sync_pb::ReadingListSpecifics::UNREAD && |
438 lhs.status() == sync_pb::ReadingListSpecifics::READ)) | 441 lhs.status() == sync_pb::ReadingListSpecifics::READ)) |
439 return false; | 442 return false; |
440 } | 443 } |
| 444 if (rhs.update_title_time_us() == lhs.update_title_time_us()) { |
| 445 if (rhs.title().compare(lhs.title()) < 0) |
| 446 return false; |
| 447 } |
441 if (rhs.creation_time_us() == lhs.creation_time_us()) { | 448 if (rhs.creation_time_us() == lhs.creation_time_us()) { |
442 if (rhs.first_read_time_us() == 0 && lhs.first_read_time_us() != 0) { | 449 if (rhs.first_read_time_us() == 0 && lhs.first_read_time_us() != 0) { |
443 return false; | 450 return false; |
444 } | 451 } |
445 if (rhs.first_read_time_us() > lhs.first_read_time_us() && | 452 if (rhs.first_read_time_us() > lhs.first_read_time_us() && |
446 lhs.first_read_time_us() != 0) { | 453 lhs.first_read_time_us() != 0) { |
447 return false; | 454 return false; |
448 } | 455 } |
449 } | 456 } |
450 return true; | 457 return true; |
451 } | 458 } |
OLD | NEW |