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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
83 std::unique_ptr<sync_pb::ReadingListSpecifics> AsReadingListSpecifics() const; | 83 std::unique_ptr<sync_pb::ReadingListSpecifics> AsReadingListSpecifics() const; |
84 | 84 |
85 // Created a ReadingListEntry from the protobuf format. | 85 // Created a ReadingListEntry from the protobuf format. |
86 static std::unique_ptr<ReadingListEntry> FromReadingListLocal( | 86 static std::unique_ptr<ReadingListEntry> FromReadingListLocal( |
87 const reading_list::ReadingListLocal& pb_entry); | 87 const reading_list::ReadingListLocal& pb_entry); |
88 | 88 |
89 // Created a ReadingListEntry from the protobuf format. | 89 // Created a ReadingListEntry from the protobuf format. |
90 static std::unique_ptr<ReadingListEntry> FromReadingListSpecifics( | 90 static std::unique_ptr<ReadingListEntry> FromReadingListSpecifics( |
91 const sync_pb::ReadingListSpecifics& pb_entry); | 91 const sync_pb::ReadingListSpecifics& pb_entry); |
92 | 92 |
93 // Merge the local data from |other| to this. | 93 // Merge |this| and |other| into this. |
94 // The local fields (distilled_state_, distilled_url_, backoff_, | 94 // Local fields are kept from |this|. |
95 // failed_download_counter_) of |other| are moved to |this| and must not be | 95 // If |other.UpdateTime()| >= |this.UpdateTime()|, all fields are copied from |
gambard
2016/12/07 10:28:49
"all fields are copied" is misleading: you do not
| |
96 // used after this call. | 96 // |other|. |
97 void MergeLocalStateFrom(ReadingListEntry& other); | 97 // If one of the state is UNSEEN, the other state is kept. |
98 // | |
99 // After calling |MergeLocalStateFrom|, the result must verify | |
100 // ReadingListStore.CompareEntriesForSync(old_this.AsReadingListSpecifics(), | |
101 // new_this.AsReadingListSpecifics()) | |
102 // and | |
103 // ReadingListStore.CompareEntriesForSync(other.AsReadingListSpecifics(), | |
104 // new_this.AsReadingListSpecifics()). | |
105 void MergeWithEntry(const ReadingListEntry& other); | |
98 | 106 |
99 ReadingListEntry& operator=(ReadingListEntry&& other); | 107 ReadingListEntry& operator=(ReadingListEntry&& other); |
100 | 108 |
101 bool operator==(const ReadingListEntry& other) const; | 109 bool operator==(const ReadingListEntry& other) const; |
102 | 110 |
103 // Returns whether |lhs| is more recent than |rhs|. | |
104 static bool CompareEntryUpdateTime(const ReadingListEntry& lhs, | |
105 const ReadingListEntry& rhs); | |
106 | |
107 // Sets the title. | 111 // Sets the title. |
108 void SetTitle(const std::string& title); | 112 void SetTitle(const std::string& title); |
109 // Sets the distilled URL and switch the state to PROCESSED and reset the time | 113 // Sets the distilled URL and switch the state to PROCESSED and reset the time |
110 // until the next try. | 114 // until the next try. |
111 void SetDistilledPath(const base::FilePath& path); | 115 void SetDistilledPath(const base::FilePath& path); |
112 // Sets the state to one of PROCESSING, WILL_RETRY or ERROR. | 116 // Sets the state to one of PROCESSING, WILL_RETRY or ERROR. |
113 void SetDistilledState(DistillationState distilled_state); | 117 void SetDistilledState(DistillationState distilled_state); |
114 // Sets the read state of the entry. Will set the UpdateTime of the entry. | 118 // Sets the read state of the entry. Will set the UpdateTime of the entry. |
115 void SetRead(bool read); | 119 void SetRead(bool read); |
116 | 120 |
(...skipping 20 matching lines...) Expand all Loading... | |
137 // These value are in microseconds since Jan 1st 1970. They are used for | 141 // These value are in microseconds since Jan 1st 1970. They are used for |
138 // sorting the entries from the database. They are kept in int64_t to avoid | 142 // sorting the entries from the database. They are kept in int64_t to avoid |
139 // conversion on each save/read event. | 143 // conversion on each save/read event. |
140 int64_t creation_time_us_; | 144 int64_t creation_time_us_; |
141 int64_t update_time_us_; | 145 int64_t update_time_us_; |
142 | 146 |
143 DISALLOW_COPY_AND_ASSIGN(ReadingListEntry); | 147 DISALLOW_COPY_AND_ASSIGN(ReadingListEntry); |
144 }; | 148 }; |
145 | 149 |
146 #endif // COMPONENTS_READING_LIST_IOS_READING_LIST_ENTRY_H_ | 150 #endif // COMPONENTS_READING_LIST_IOS_READING_LIST_ENTRY_H_ |
OLD | NEW |