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

Unified Diff: components/offline_pages/background/request_picker.cc

Issue 2176393004: Add expiration policy, code to check it, and a test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR feedback per DougArnett Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: components/offline_pages/background/request_picker.cc
diff --git a/components/offline_pages/background/request_picker.cc b/components/offline_pages/background/request_picker.cc
index 23fee192c99f27f8152c66bdb61bc5ae6dfc8664..c6ac59ebb38d5d2a8c1f4c029567cb260bd5aef3 100644
--- a/components/offline_pages/background/request_picker.cc
+++ b/components/offline_pages/background/request_picker.cc
@@ -114,6 +114,14 @@ bool RequestPicker::RequestConditionsSatisfied(const SavePageRequest& request) {
if (request.attempt_count() >= policy_->GetMaxRetries())
return false;
+ // If the request is expired, do not consider it.
+ // TODO(petewil): We need to remove this from the queue.
+ base::TimeDelta requestAge = base::Time::Now() - request.creation_time();
+ if (requestAge >
+ base::TimeDelta::FromSeconds(
+ policy_->GetRequestExpirationTimeInSeconds()))
+ return false;
+
// If this request is not active yet, return false.
// TODO(petewil): If the only reason we return nothing to do is that we have
// inactive requests, we still want to try again later after their activation
« no previous file with comments | « components/offline_pages/background/offliner_policy.h ('k') | components/offline_pages/background/request_picker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698