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 GURL& URL() const; | 54 const GURL& URL() const; |
55 // The title of the entry. Might be empty. | 55 // The title of the entry. Might be empty. |
56 const std::string& Title() const; | 56 const std::string& Title() const; |
57 // What state this entry is in. | 57 // What state this entry is in. |
58 DistillationState DistilledState() const; | 58 DistillationState DistilledState() const; |
59 // The local file path for the distilled version of the page. This should only | 59 // The local file path for the distilled version of the page. This should only |
60 // be called if the state is "PROCESSED". | 60 // be called if the state is "PROCESSED". |
61 const base::FilePath& DistilledPath() const; | 61 const base::FilePath& DistilledPath() const; |
62 // The URL that has been distilled to produce file stored at |DistilledPath|. | 62 // The URL that has been distilled to produce file stored at |DistilledPath|. |
63 const GURL& DistilledURL() const; | 63 const GURL& DistilledURL() const; |
| 64 // The time distillation was done. The value is in microseconds since Jan 1st |
| 65 // 1970. |
| 66 int64_t DistillationTime() const; |
| 67 // The size of the stored page in bytes. |
| 68 int64_t DistillationSize() const; |
64 // The time before the next try. This is automatically increased when the | 69 // The time before the next try. This is automatically increased when the |
65 // state is set to WILL_RETRY or ERROR from a non-error state. | 70 // state is set to WILL_RETRY or ERROR from a non-error state. |
66 base::TimeDelta TimeUntilNextTry() const; | 71 base::TimeDelta TimeUntilNextTry() const; |
67 // The number of time chrome failed to download this entry. This is | 72 // The number of time chrome failed to download this entry. This is |
68 // automatically increased when the state is set to WILL_RETRY or ERROR from a | 73 // automatically increased when the state is set to WILL_RETRY or ERROR from a |
69 // non-error state. | 74 // non-error state. |
70 int FailedDownloadCounter() const; | 75 int FailedDownloadCounter() const; |
71 // The read status of the entry. | 76 // The read status of the entry. |
72 bool IsRead() const; | 77 bool IsRead() const; |
73 // Returns if an entry has ever been seen. | 78 // Returns if an entry has ever been seen. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 // ReadingListStore.CompareEntriesForSync(other.AsReadingListSpecifics(), | 124 // ReadingListStore.CompareEntriesForSync(other.AsReadingListSpecifics(), |
120 // new_this.AsReadingListSpecifics()). | 125 // new_this.AsReadingListSpecifics()). |
121 void MergeWithEntry(const ReadingListEntry& other); | 126 void MergeWithEntry(const ReadingListEntry& other); |
122 | 127 |
123 ReadingListEntry& operator=(ReadingListEntry&& other); | 128 ReadingListEntry& operator=(ReadingListEntry&& other); |
124 | 129 |
125 bool operator==(const ReadingListEntry& other) const; | 130 bool operator==(const ReadingListEntry& other) const; |
126 | 131 |
127 // Sets the title. | 132 // Sets the title. |
128 void SetTitle(const std::string& title); | 133 void SetTitle(const std::string& title); |
129 // Sets the distilled info (offline path and online URL) about distilled page, | 134 // Sets the distilled info (offline path, online URL and size of the stored |
130 // switch the state to PROCESSED and reset the time until the next try. | 135 // files) about distilled page, switch the state to PROCESSED and reset the |
131 void SetDistilledInfo(const base::FilePath& path, const GURL& distilled_url); | 136 // time until the next try. |
| 137 void SetDistilledInfo(const base::FilePath& path, |
| 138 const GURL& distilled_url, |
| 139 int64_t size); |
132 // Sets the state to one of PROCESSING, WILL_RETRY or ERROR. | 140 // Sets the state to one of PROCESSING, WILL_RETRY or ERROR. |
133 void SetDistilledState(DistillationState distilled_state); | 141 void SetDistilledState(DistillationState distilled_state); |
134 // Sets the read state of the entry. Will set the UpdateTime of the entry. | 142 // Sets the read state of the entry. Will set the UpdateTime of the entry. |
135 void SetRead(bool read); | 143 void SetRead(bool read); |
136 | 144 |
137 private: | 145 private: |
138 enum State { UNSEEN, UNREAD, READ }; | 146 enum State { UNSEEN, UNREAD, READ }; |
139 ReadingListEntry(const GURL& url, | 147 ReadingListEntry(const GURL& url, |
140 const std::string& title, | 148 const std::string& title, |
141 State state, | 149 State state, |
142 int64_t creation_time, | 150 int64_t creation_time, |
143 int64_t first_read_time, | 151 int64_t first_read_time, |
144 int64_t update_time, | 152 int64_t update_time, |
145 int64_t update_title_time, | 153 int64_t update_title_time, |
146 ReadingListEntry::DistillationState distilled_state, | 154 ReadingListEntry::DistillationState distilled_state, |
147 const base::FilePath& distilled_path, | 155 const base::FilePath& distilled_path, |
148 const GURL& distilled_url, | 156 const GURL& distilled_url, |
| 157 int64_t distillation_time, |
| 158 int64_t distillation_size, |
149 int failed_download_counter, | 159 int failed_download_counter, |
150 std::unique_ptr<net::BackoffEntry> backoff); | 160 std::unique_ptr<net::BackoffEntry> backoff); |
151 GURL url_; | 161 GURL url_; |
152 std::string title_; | 162 std::string title_; |
153 State state_; | 163 State state_; |
154 base::FilePath distilled_path_; | 164 base::FilePath distilled_path_; |
155 GURL distilled_url_; | 165 GURL distilled_url_; |
156 DistillationState distilled_state_; | 166 DistillationState distilled_state_; |
157 | 167 |
158 std::unique_ptr<net::BackoffEntry> backoff_; | 168 std::unique_ptr<net::BackoffEntry> backoff_; |
159 int failed_download_counter_; | 169 int failed_download_counter_; |
160 | 170 |
161 // These value are in microseconds since Jan 1st 1970. They are used for | 171 // These value are in microseconds since Jan 1st 1970. They are used for |
162 // sorting the entries from the database. They are kept in int64_t to avoid | 172 // sorting the entries from the database. They are kept in int64_t to avoid |
163 // conversion on each save/read event. | 173 // conversion on each save/read event. |
164 int64_t creation_time_us_; | 174 int64_t creation_time_us_; |
165 int64_t first_read_time_us_; | 175 int64_t first_read_time_us_; |
166 int64_t update_time_us_; | 176 int64_t update_time_us_; |
167 int64_t update_title_time_us_; | 177 int64_t update_title_time_us_; |
| 178 int64_t distillation_time_us_; |
| 179 int64_t distillation_size_; |
168 | 180 |
169 DISALLOW_COPY_AND_ASSIGN(ReadingListEntry); | 181 DISALLOW_COPY_AND_ASSIGN(ReadingListEntry); |
170 }; | 182 }; |
171 | 183 |
172 #endif // COMPONENTS_READING_LIST_IOS_READING_LIST_ENTRY_H_ | 184 #endif // COMPONENTS_READING_LIST_IOS_READING_LIST_ENTRY_H_ |
OLD | NEW |