| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 const base::FilePath& DistilledPath() const; | 54 const base::FilePath& DistilledPath() const; |
| 55 // The time before the next try. This is automatically increased when the | 55 // The time before the next try. This is automatically increased when the |
| 56 // state is set to WILL_RETRY or ERROR from a non-error state. | 56 // state is set to WILL_RETRY or ERROR from a non-error state. |
| 57 base::TimeDelta TimeUntilNextTry() const; | 57 base::TimeDelta TimeUntilNextTry() const; |
| 58 // The number of time chrome failed to download this entry. This is | 58 // The number of time chrome failed to download this entry. This is |
| 59 // automatically increased when the state is set to WILL_RETRY or ERROR from a | 59 // automatically increased when the state is set to WILL_RETRY or ERROR from a |
| 60 // non-error state. | 60 // non-error state. |
| 61 int FailedDownloadCounter() const; | 61 int FailedDownloadCounter() const; |
| 62 // The read status of the entry. | 62 // The read status of the entry. |
| 63 bool IsRead() const; | 63 bool IsRead() const; |
| 64 // Returns if an entry has ever been seen. |
| 65 bool HasBeenSeen() const; |
| 64 | 66 |
| 65 // The last update time of the entry. This value may be used to sort the | 67 // The last update time of the entry. This value may be used to sort the |
| 66 // entries. The value is in microseconds since Jan 1st 1970. | 68 // entries. The value is in microseconds since Jan 1st 1970. |
| 67 int64_t UpdateTime() const; | 69 int64_t UpdateTime() const; |
| 68 | 70 |
| 69 // The creation update time of the entry. The value is in microseconds since | 71 // The creation update time of the entry. The value is in microseconds since |
| 70 // Jan 1st 1970. | 72 // Jan 1st 1970. |
| 71 int64_t CreationTime() const; | 73 int64_t CreationTime() const; |
| 72 | 74 |
| 73 // Set the update time to now. | 75 // Set the update time to now. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 102 static bool CompareEntryUpdateTime(const ReadingListEntry& lhs, | 104 static bool CompareEntryUpdateTime(const ReadingListEntry& lhs, |
| 103 const ReadingListEntry& rhs); | 105 const ReadingListEntry& rhs); |
| 104 | 106 |
| 105 // Sets the title. | 107 // Sets the title. |
| 106 void SetTitle(const std::string& title); | 108 void SetTitle(const std::string& title); |
| 107 // Sets the distilled URL and switch the state to PROCESSED and reset the time | 109 // Sets the distilled URL and switch the state to PROCESSED and reset the time |
| 108 // until the next try. | 110 // until the next try. |
| 109 void SetDistilledPath(const base::FilePath& path); | 111 void SetDistilledPath(const base::FilePath& path); |
| 110 // Sets the state to one of PROCESSING, WILL_RETRY or ERROR. | 112 // Sets the state to one of PROCESSING, WILL_RETRY or ERROR. |
| 111 void SetDistilledState(DistillationState distilled_state); | 113 void SetDistilledState(DistillationState distilled_state); |
| 112 // Sets the read stat of the entry. Will set the UpdateTime of the entry. | 114 // Sets the read state of the entry. Will set the UpdateTime of the entry. |
| 113 void SetRead(bool read); | 115 void SetRead(bool read); |
| 114 | 116 |
| 115 private: | 117 private: |
| 118 enum State { UNSEEN, UNREAD, READ }; |
| 116 ReadingListEntry(const GURL& url, | 119 ReadingListEntry(const GURL& url, |
| 117 const std::string& title, | 120 const std::string& title, |
| 118 bool read, | 121 State state, |
| 119 int64_t creation_time, | 122 int64_t creation_time, |
| 120 int64_t update_time, | 123 int64_t update_time, |
| 121 ReadingListEntry::DistillationState distilled_state, | 124 ReadingListEntry::DistillationState distilled_state, |
| 122 const base::FilePath& distilled_path, | 125 const base::FilePath& distilled_path, |
| 123 int failed_download_counter, | 126 int failed_download_counter, |
| 124 std::unique_ptr<net::BackoffEntry> backoff); | 127 std::unique_ptr<net::BackoffEntry> backoff); |
| 125 GURL url_; | 128 GURL url_; |
| 126 std::string title_; | 129 std::string title_; |
| 127 bool read_; | 130 State state_; |
| 128 base::FilePath distilled_path_; | 131 base::FilePath distilled_path_; |
| 129 DistillationState distilled_state_; | 132 DistillationState distilled_state_; |
| 130 | 133 |
| 131 std::unique_ptr<net::BackoffEntry> backoff_; | 134 std::unique_ptr<net::BackoffEntry> backoff_; |
| 132 int failed_download_counter_; | 135 int failed_download_counter_; |
| 133 | 136 |
| 134 // These value are in microseconds since Jan 1st 1970. They are used for | 137 // These value are in microseconds since Jan 1st 1970. They are used for |
| 135 // sorting the entries from the database. They are kept in int64_t to avoid | 138 // sorting the entries from the database. They are kept in int64_t to avoid |
| 136 // conversion on each save/read event. | 139 // conversion on each save/read event. |
| 137 int64_t creation_time_us_; | 140 int64_t creation_time_us_; |
| 138 int64_t update_time_us_; | 141 int64_t update_time_us_; |
| 139 | 142 |
| 140 DISALLOW_COPY_AND_ASSIGN(ReadingListEntry); | 143 DISALLOW_COPY_AND_ASSIGN(ReadingListEntry); |
| 141 }; | 144 }; |
| 142 | 145 |
| 143 #endif // COMPONENTS_READING_LIST_IOS_READING_LIST_ENTRY_H_ | 146 #endif // COMPONENTS_READING_LIST_IOS_READING_LIST_ENTRY_H_ |
| OLD | NEW |