| 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 #ifndef COMPONENTS_READING_LIST_IOS_READING_LIST_ENTRY_H_ | 5 #ifndef COMPONENTS_READING_LIST_IOS_READING_LIST_ENTRY_H_ |
| 6 #define COMPONENTS_READING_LIST_IOS_READING_LIST_ENTRY_H_ | 6 #define COMPONENTS_READING_LIST_IOS_READING_LIST_ENTRY_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 std::unique_ptr<sync_pb::ReadingListSpecifics> AsReadingListSpecifics() const; | 87 std::unique_ptr<sync_pb::ReadingListSpecifics> AsReadingListSpecifics() const; |
| 88 | 88 |
| 89 // Created a ReadingListEntry from the protobuf format. | 89 // Created a ReadingListEntry from the protobuf format. |
| 90 static std::unique_ptr<ReadingListEntry> FromReadingListLocal( | 90 static std::unique_ptr<ReadingListEntry> FromReadingListLocal( |
| 91 const reading_list::ReadingListLocal& pb_entry); | 91 const reading_list::ReadingListLocal& pb_entry); |
| 92 | 92 |
| 93 // Created a ReadingListEntry from the protobuf format. | 93 // Created a ReadingListEntry from the protobuf format. |
| 94 static std::unique_ptr<ReadingListEntry> FromReadingListSpecifics( | 94 static std::unique_ptr<ReadingListEntry> FromReadingListSpecifics( |
| 95 const sync_pb::ReadingListSpecifics& pb_entry); | 95 const sync_pb::ReadingListSpecifics& pb_entry); |
| 96 | 96 |
| 97 // Merge the local data from |other| to this. | 97 // Merge |this| and |other| into this. |
| 98 // The local fields (distilled_state_, distilled_url_, backoff_, | 98 // Local fields are kept from |this|. |
| 99 // failed_download_counter_) of |other| are moved to |this| and must not be | 99 // Each field is merged individually keeping the highest value as defined by |
| 100 // used after this call. | 100 // the |ReadingListStore.CompareEntriesForSync| function. |
| 101 void MergeLocalStateFrom(ReadingListEntry& other); | 101 // |
| 102 // After calling |MergeLocalStateFrom|, the result must verify |
| 103 // ReadingListStore.CompareEntriesForSync(old_this.AsReadingListSpecifics(), |
| 104 // new_this.AsReadingListSpecifics()) |
| 105 // and |
| 106 // ReadingListStore.CompareEntriesForSync(other.AsReadingListSpecifics(), |
| 107 // new_this.AsReadingListSpecifics()). |
| 108 void MergeWithEntry(const ReadingListEntry& other); |
| 102 | 109 |
| 103 ReadingListEntry& operator=(ReadingListEntry&& other); | 110 ReadingListEntry& operator=(ReadingListEntry&& other); |
| 104 | 111 |
| 105 bool operator==(const ReadingListEntry& other) const; | 112 bool operator==(const ReadingListEntry& other) const; |
| 106 | 113 |
| 107 // Returns whether |lhs| is more recent than |rhs|. | |
| 108 static bool CompareEntryUpdateTime(const ReadingListEntry& lhs, | |
| 109 const ReadingListEntry& rhs); | |
| 110 | |
| 111 // Sets the title. | 114 // Sets the title. |
| 112 void SetTitle(const std::string& title); | 115 void SetTitle(const std::string& title); |
| 113 // Sets the distilled URL and switch the state to PROCESSED and reset the time | 116 // Sets the distilled URL and switch the state to PROCESSED and reset the time |
| 114 // until the next try. | 117 // until the next try. |
| 115 void SetDistilledPath(const base::FilePath& path); | 118 void SetDistilledPath(const base::FilePath& path); |
| 116 // Sets the state to one of PROCESSING, WILL_RETRY or ERROR. | 119 // Sets the state to one of PROCESSING, WILL_RETRY or ERROR. |
| 117 void SetDistilledState(DistillationState distilled_state); | 120 void SetDistilledState(DistillationState distilled_state); |
| 118 // Sets the read state of the entry. Will set the UpdateTime of the entry. | 121 // Sets the read state of the entry. Will set the UpdateTime of the entry. |
| 119 void SetRead(bool read); | 122 void SetRead(bool read); |
| 120 | 123 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 143 // sorting the entries from the database. They are kept in int64_t to avoid | 146 // sorting the entries from the database. They are kept in int64_t to avoid |
| 144 // conversion on each save/read event. | 147 // conversion on each save/read event. |
| 145 int64_t creation_time_us_; | 148 int64_t creation_time_us_; |
| 146 int64_t first_read_time_us_; | 149 int64_t first_read_time_us_; |
| 147 int64_t update_time_us_; | 150 int64_t update_time_us_; |
| 148 | 151 |
| 149 DISALLOW_COPY_AND_ASSIGN(ReadingListEntry); | 152 DISALLOW_COPY_AND_ASSIGN(ReadingListEntry); |
| 150 }; | 153 }; |
| 151 | 154 |
| 152 #endif // COMPONENTS_READING_LIST_IOS_READING_LIST_ENTRY_H_ | 155 #endif // COMPONENTS_READING_LIST_IOS_READING_LIST_ENTRY_H_ |
| OLD | NEW |