Chromium Code Reviews| Index: ios/chrome/browser/reading_list/reading_list_entry.h |
| diff --git a/ios/chrome/browser/reading_list/reading_list_entry.h b/ios/chrome/browser/reading_list/reading_list_entry.h |
| index 3ed4903e8e6226a817acd367e997cb5fc1a8fa0b..ccf1b130d370fdcb677b72bc3917b1efc4319170 100644 |
| --- a/ios/chrome/browser/reading_list/reading_list_entry.h |
| +++ b/ios/chrome/browser/reading_list/reading_list_entry.h |
| @@ -6,28 +6,43 @@ |
| #define IOS_CHROME_BROWSER_READING_LIST_READING_LIST_ENTRY_H_ |
| #include <string> |
| +#include <vector> |
| #include "base/macros.h" |
| +#include "base/time/default_tick_clock.h" |
| +#include "base/time/time.h" |
| #include "net/base/backoff_entry.h" |
| #include "url/gurl.h" |
| +namespace sync_pb { |
| +class ReadingListLocal; |
| +} |
| + |
| // An entry in the reading list. The URL is a unique identifier for an entry, as |
| // such it should not be empty and is the only thing considered when comparing |
| // entries. |
| class ReadingListEntry { |
| public: |
| + // Entries are created in WAITING state. At some point they will be PROCESSING |
| + // into one of the three state: PROCESSED, the only state a distilled URL |
| + // would be set, WILL_RETRY, similar to wait, but with exponential delays or |
| + // ERROR where the system will not retry at all. |
| + enum DistillationState { WAITING, PROCESSING, PROCESSED, WILL_RETRY, ERROR }; |
| + |
| ReadingListEntry(const GURL& url, const std::string& title); |
| ReadingListEntry(const GURL& url, |
| const std::string& title, |
| std::unique_ptr<net::BackoffEntry> backoff); |
| + ReadingListEntry(const GURL& url, |
| + const std::string& title, |
| + int64_t creation_time, |
| + int64_t update_time, |
| + DistillationState distilled_state, |
| + const GURL& distilled_url, |
| + std::unique_ptr<net::BackoffEntry> backoff); |
| ReadingListEntry(ReadingListEntry&& entry); |
| ~ReadingListEntry(); |
| - // Entries are created in WAITING state. At some point they will be PROCESSING |
| - // into one of the three state: PROCESSED, the only state a distilled URL |
| - // would be set, WILL_RETRY, similar to wait, but with exponential delays or |
| - // ERROR where the system will not retry at all. |
| - enum DistillationState { WAITING, PROCESSING, PROCESSED, WILL_RETRY, ERROR }; |
| static const net::BackoffEntry::Policy kBackoffPolicy; |
| @@ -48,9 +63,29 @@ class ReadingListEntry { |
| // non-error state. |
| int FailedDownloadCounter() const; |
| + // The last update time of the entry. Thes value may be used to sort the |
|
jif-google
2016/09/27 16:39:03
s/Thes/These/
gambard
2016/09/28 09:19:08
I think it is s/Thes/This/
Olivier
2016/09/28 11:20:06
Done.
|
| + // entries. |
| + int64_t UpdateTime() const; |
|
jif-google
2016/09/27 16:39:03
use base::time instead of int64_t ?
If not, then p
Olivier
2016/09/28 11:20:06
I did use base::time, but as the value is used onl
|
| + |
| + // Set the update time to now. |
| + void MarkEntryUpdated(); |
| + |
| + // Converts a ReadingListEntry to the protobuf format. |
|
jif-google
2016/09/27 16:39:03
How about:
// Returns a protobuf encoding the cont
Olivier
2016/09/28 11:20:06
Done.
|
| + std::unique_ptr<sync_pb::ReadingListLocal> AsReadingListLocal( |
| + bool read) const; |
| + |
| + // Created a ReadingListEntry from the protobuf format. |
| + static std::unique_ptr<ReadingListEntry> FromReadingListLocal( |
| + const sync_pb::ReadingListLocal& pb_entry); |
| + |
| ReadingListEntry& operator=(ReadingListEntry&& other); |
| + |
| bool operator==(const ReadingListEntry& other) const; |
| + // Compares two entries using update time, most recent first. |
|
gambard
2016/09/28 09:19:08
Maybe be a bit more explicit? Like // returns whet
Olivier
2016/09/28 11:20:06
Done.
|
| + static bool CompareEntryUpdateTime(const ReadingListEntry& lhs, |
| + const ReadingListEntry& rhs); |
| + |
| // Sets the title. |
| void SetTitle(const std::string& title); |
| // Sets the distilled URL and switch the state to PROCESSED and reset the time |
| @@ -64,10 +99,15 @@ class ReadingListEntry { |
| std::string title_; |
| GURL distilled_url_; |
| DistillationState distilled_state_; |
| + |
| std::unique_ptr<net::BackoffEntry> backoff_; |
| int failed_download_counter_; |
| + int64_t creation_time_us_; |
|
jif-google
2016/09/27 16:39:03
base::time ?
gambard
2016/09/28 09:19:08
what do the "us" part of the variable name mean? C
Olivier
2016/09/28 11:20:06
same comment as above.
This value is fundamentally
|
| + int64_t update_time_us_; |
| DISALLOW_COPY_AND_ASSIGN(ReadingListEntry); |
| }; |
| +typedef std::vector<ReadingListEntry> ReadingListEntries; |
|
jif-google
2016/09/27 16:39:03
Use "using" instead of "typedef". It's better, and
jif-google
2016/09/27 16:39:03
move ReadingListEntries definition to where it's u
Olivier
2016/09/28 11:20:06
Done.
|
| + |
| #endif // IOS_CHROME_BROWSER_READING_LIST_READING_LIST_ENTRY_H_ |