Chromium Code Reviews| Index: ios/chrome/browser/reading_list/reading_list_entry.cc |
| diff --git a/ios/chrome/browser/reading_list/reading_list_entry.cc b/ios/chrome/browser/reading_list/reading_list_entry.cc |
| index bea3f83d348ca4aca4cee98b19fed190764e968f..5ff3dbc35c7ea75c792c3d13c8304fac99b854f5 100644 |
| --- a/ios/chrome/browser/reading_list/reading_list_entry.cc |
| +++ b/ios/chrome/browser/reading_list/reading_list_entry.cc |
| @@ -6,6 +6,12 @@ |
| #include "base/memory/ptr_util.h" |
| +namespace { |
| +// URL used to open offline pages. |
|
jif-google
2016/11/10 15:48:24
To be more exact:
// Scheme and prefix used to ope
jif-google
2016/11/10 15:51:35
I'm wrong, "chrome://offline/" is actually a URL.
|
| +// This variable will be moved to chrome_url_constants. |
| +const char kChromeUIOfflineURL[] = "chrome://offline/"; |
| +} |
| + |
| // The backoff time is the following: 10min, 10min, 1h, 2h, 2h..., starting |
| // after the first failure. |
| const net::BackoffEntry::Policy ReadingListEntry::kBackoffPolicy = { |
| @@ -55,7 +61,7 @@ ReadingListEntry::ReadingListEntry(const GURL& url, |
| ReadingListEntry::ReadingListEntry(ReadingListEntry&& entry) |
| : url_(std::move(entry.url_)), |
| title_(std::move(entry.title_)), |
| - distilled_url_(std::move(entry.distilled_url_)), |
| + distilled_path_(std::move(entry.distilled_path_)), |
| distilled_state_(std::move(entry.distilled_state_)), |
| backoff_(std::move(entry.backoff_)), |
| failed_download_counter_(std::move(entry.failed_download_counter_)) {} |
| @@ -74,8 +80,15 @@ ReadingListEntry::DistillationState ReadingListEntry::DistilledState() const { |
| return distilled_state_; |
| } |
| -const GURL& ReadingListEntry::DistilledURL() const { |
| - return distilled_url_; |
| +const base::FilePath& ReadingListEntry::DistilledPath() const { |
| + return distilled_path_; |
| +} |
| + |
| +const GURL ReadingListEntry::DistilledURL() const { |
| + if (distilled_path_.empty()) { |
| + return GURL(); |
| + } |
| + return GURL(kChromeUIOfflineURL + distilled_path_.value()); |
| } |
| base::TimeDelta ReadingListEntry::TimeUntilNextTry() const { |
| @@ -89,7 +102,7 @@ int ReadingListEntry::FailedDownloadCounter() const { |
| ReadingListEntry& ReadingListEntry::operator=(ReadingListEntry&& other) { |
| url_ = std::move(other.url_); |
| title_ = std::move(other.title_); |
| - distilled_url_ = std::move(other.distilled_url_); |
| + distilled_path_ = std::move(other.distilled_path_); |
| distilled_state_ = std::move(other.distilled_state_); |
| backoff_ = std::move(other.backoff_); |
| failed_download_counter_ = std::move(other.failed_download_counter_); |
| @@ -104,16 +117,16 @@ void ReadingListEntry::SetTitle(const std::string& title) { |
| title_ = title; |
| } |
| -void ReadingListEntry::SetDistilledURL(const GURL& url) { |
| - DCHECK(url.is_valid()); |
| - distilled_url_ = url; |
| +void ReadingListEntry::SetDistilledPath(const base::FilePath& path) { |
| + DCHECK(!path.empty()); |
| + distilled_path_ = path; |
| distilled_state_ = PROCESSED; |
| backoff_->Reset(); |
| failed_download_counter_ = 0; |
| } |
| void ReadingListEntry::SetDistilledState(DistillationState distilled_state) { |
| - DCHECK(distilled_state != PROCESSED); // use SetDistilledURL instead. |
| + DCHECK(distilled_state != PROCESSED); // use SetDistilledPath instead. |
| DCHECK(distilled_state != WAITING); |
| // Increase time until next retry exponentially if the state change from a |
| // non-error state to an error state. |
| @@ -124,5 +137,5 @@ void ReadingListEntry::SetDistilledState(DistillationState distilled_state) { |
| } |
| distilled_state_ = distilled_state; |
| - distilled_url_ = GURL(); |
| + distilled_path_ = base::FilePath(); |
| } |