Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Side by Side Diff: ios/chrome/browser/reading_list/reading_list_entry.cc

Issue 2506993002: Create offline_url_utils (Closed)
Patch Set: feedback Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "ios/chrome/browser/reading_list/reading_list_entry.h" 5 #include "ios/chrome/browser/reading_list/reading_list_entry.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 8 #include "ios/chrome/browser/reading_list/offline_url_utils.h"
9 namespace {
10 // URL used to open offline pages.
11 // This variable will be moved to chrome_url_constants.
12 const char kChromeUIOfflineURL[] = "chrome://offline/";
13 }
14 9
15 // The backoff time is the following: 10min, 10min, 1h, 2h, 2h..., starting 10 // The backoff time is the following: 10min, 10min, 1h, 2h, 2h..., starting
16 // after the first failure. 11 // after the first failure.
17 const net::BackoffEntry::Policy ReadingListEntry::kBackoffPolicy = { 12 const net::BackoffEntry::Policy ReadingListEntry::kBackoffPolicy = {
18 // Number of initial errors (in sequence) to ignore before applying 13 // Number of initial errors (in sequence) to ignore before applying
19 // exponential back-off rules. 14 // exponential back-off rules.
20 2, 15 2,
21 16
22 // Initial delay for exponential back-off in ms. 17 // Initial delay for exponential back-off in ms.
23 10 * 60 * 1000, // 10 minutes. 18 10 * 60 * 1000, // 10 minutes.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 73
79 ReadingListEntry::DistillationState ReadingListEntry::DistilledState() const { 74 ReadingListEntry::DistillationState ReadingListEntry::DistilledState() const {
80 return distilled_state_; 75 return distilled_state_;
81 } 76 }
82 77
83 const base::FilePath& ReadingListEntry::DistilledPath() const { 78 const base::FilePath& ReadingListEntry::DistilledPath() const {
84 return distilled_path_; 79 return distilled_path_;
85 } 80 }
86 81
87 const GURL ReadingListEntry::DistilledURL() const { 82 const GURL ReadingListEntry::DistilledURL() const {
88 if (distilled_path_.empty()) { 83 return reading_list::DistilledURLForPath(distilled_path_);
89 return GURL();
90 }
91 return GURL(kChromeUIOfflineURL + distilled_path_.value());
92 } 84 }
93 85
94 base::TimeDelta ReadingListEntry::TimeUntilNextTry() const { 86 base::TimeDelta ReadingListEntry::TimeUntilNextTry() const {
95 return backoff_->GetTimeUntilRelease(); 87 return backoff_->GetTimeUntilRelease();
96 } 88 }
97 89
98 int ReadingListEntry::FailedDownloadCounter() const { 90 int ReadingListEntry::FailedDownloadCounter() const {
99 return failed_download_counter_; 91 return failed_download_counter_;
100 } 92 }
101 93
(...skipping 30 matching lines...) Expand all
132 // non-error state to an error state. 124 // non-error state to an error state.
133 if ((distilled_state == WILL_RETRY || distilled_state == ERROR) && 125 if ((distilled_state == WILL_RETRY || distilled_state == ERROR) &&
134 distilled_state_ != WILL_RETRY && distilled_state_ != ERROR) { 126 distilled_state_ != WILL_RETRY && distilled_state_ != ERROR) {
135 backoff_->InformOfRequest(false); 127 backoff_->InformOfRequest(false);
136 failed_download_counter_++; 128 failed_download_counter_++;
137 } 129 }
138 130
139 distilled_state_ = distilled_state; 131 distilled_state_ = distilled_state;
140 distilled_path_ = base::FilePath(); 132 distilled_path_ = base::FilePath();
141 } 133 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/reading_list/offline_url_utils_unittest.cc ('k') | ios/chrome/browser/reading_list/url_downloader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698