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

Side by Side Diff: components/offline_pages/background/request_picker.cc

Issue 2191733004: [Offline Pages] Configure for no retries (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months 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
« no previous file with comments | « components/offline_pages/background/request_coordinator.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "components/offline_pages/background/request_picker.h" 5 #include "components/offline_pages/background/request_picker.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "components/offline_pages/background/save_page_request.h" 9 #include "components/offline_pages/background/save_page_request.h"
10 10
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 if (current_conditions_->GetBatteryPercentage() < 104 if (current_conditions_->GetBatteryPercentage() <
105 policy_->GetMinimumBatteryPercentageForNonUserRequestOfflining()) { 105 policy_->GetMinimumBatteryPercentageForNonUserRequestOfflining()) {
106 return false; 106 return false;
107 } 107 }
108 } 108 }
109 109
110 // If we have already tried this page the max number of times, it is not 110 // If we have already tried this page the max number of times, it is not
111 // eligible to try again. 111 // eligible to try again.
112 // TODO(petewil): Instead, we should have code to remove the page from the 112 // TODO(petewil): Instead, we should have code to remove the page from the
113 // queue after the last retry. 113 // queue after the last retry.
114 if (request.attempt_count() >= policy_->GetMaxRetries()) 114 if (request.attempt_count() > policy_->GetMaxTries())
115 return false; 115 return false;
116 116
117 // If the request is expired, do not consider it. 117 // If the request is expired, do not consider it.
118 // TODO(petewil): We need to remove this from the queue. 118 // TODO(petewil): We need to remove this from the queue.
119 base::TimeDelta requestAge = base::Time::Now() - request.creation_time(); 119 base::TimeDelta requestAge = base::Time::Now() - request.creation_time();
120 if (requestAge > 120 if (requestAge >
121 base::TimeDelta::FromSeconds( 121 base::TimeDelta::FromSeconds(
122 policy_->GetRequestExpirationTimeInSeconds())) 122 policy_->GetRequestExpirationTimeInSeconds()))
123 return false; 123 return false;
124 124
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 int result = signum(difference.InMilliseconds()); 205 int result = signum(difference.InMilliseconds());
206 206
207 // Flip the direction of comparison if policy prefers fewer retries. 207 // Flip the direction of comparison if policy prefers fewer retries.
208 if (earlier_requests_better_) 208 if (earlier_requests_better_)
209 result *= -1; 209 result *= -1;
210 210
211 return result; 211 return result;
212 } 212 }
213 213
214 } // namespace offline_pages 214 } // namespace offline_pages
OLDNEW
« no previous file with comments | « components/offline_pages/background/request_coordinator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698