Chromium Code Reviews| Index: components/reading_list/ios/reading_list_entry.cc |
| diff --git a/components/reading_list/ios/reading_list_entry.cc b/components/reading_list/ios/reading_list_entry.cc |
| index 283d78a924fb9a66310822bfcc40c330e0e00458..43f98de6227854ef9b88f74a19bff13091b129b5 100644 |
| --- a/components/reading_list/ios/reading_list_entry.cc |
| +++ b/components/reading_list/ios/reading_list_entry.cc |
| @@ -8,6 +8,7 @@ |
| #include "base/memory/ptr_util.h" |
| #include "components/reading_list/ios/offline_url_utils.h" |
| #include "components/reading_list/ios/proto/reading_list.pb.h" |
| +#include "components/reading_list/ios/reading_list_store.h" |
| #include "components/sync/protocol/reading_list_specifics.pb.h" |
| #include "net/base/backoff_entry_serializer.h" |
| @@ -327,11 +328,29 @@ std::unique_ptr<ReadingListEntry> ReadingListEntry::FromReadingListSpecifics( |
| WAITING, base::FilePath(), 0, nullptr)); |
| } |
| -void ReadingListEntry::MergeLocalStateFrom(ReadingListEntry& other) { |
| - distilled_path_ = std::move(other.distilled_path_); |
| - distilled_state_ = std::move(other.distilled_state_); |
| - backoff_ = std::move(other.backoff_); |
| - failed_download_counter_ = std::move(other.failed_download_counter_); |
| +void ReadingListEntry::MergeWithEntry(const ReadingListEntry& other) { |
| +#if !defined(NDEBUG) |
| + // Checks that the result entry respect the sync order. |
|
jif
2016/12/07 08:25:36
s/respect/respects/
Olivier
2016/12/07 12:00:21
Done.
|
| + std::unique_ptr<sync_pb::ReadingListSpecifics> old_this_pb( |
| + AsReadingListSpecifics()); |
| + std::unique_ptr<sync_pb::ReadingListSpecifics> other_pb( |
| + other.AsReadingListSpecifics()); |
| +#endif |
| + if (other.UpdateTime() >= UpdateTime()) { |
| + url_ = std::move(other.url_); |
| + title_ = std::move(other.title_); |
| + creation_time_us_ = std::move(other.creation_time_us_); |
| + update_time_us_ = std::move(other.update_time_us_); |
| + if (other.state_ != UNSEEN) { |
| + state_ = std::move(other.state_); |
| + } |
| + } |
| +#if !defined(NDEBUG) |
| + std::unique_ptr<sync_pb::ReadingListSpecifics> new_this_pb( |
| + AsReadingListSpecifics()); |
| + DCHECK(ReadingListStore::CompareEntriesForSync(*old_this_pb, *new_this_pb)); |
| + DCHECK(ReadingListStore::CompareEntriesForSync(*other_pb, *new_this_pb)); |
| +#endif |
| } |
| std::unique_ptr<reading_list::ReadingListLocal> |
| @@ -423,8 +442,3 @@ ReadingListEntry::AsReadingListSpecifics() const { |
| return pb_entry; |
| } |
| - |
| -bool ReadingListEntry::CompareEntryUpdateTime(const ReadingListEntry& lhs, |
| - const ReadingListEntry& rhs) { |
| - return lhs.UpdateTime() > rhs.UpdateTime(); |
| -} |