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

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

Issue 2543093002: Split the RequestPicker task into two separate tasks. (Closed)
Patch Set: ADD TODO Created 4 years 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/offliner_policy_utils.cc
diff --git a/components/offline_pages/background/offliner_policy_utils.cc b/components/offline_pages/background/offliner_policy_utils.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e9cfc1279a7df82a07c6d53489cc56a6d8e294bf
--- /dev/null
+++ b/components/offline_pages/background/offliner_policy_utils.cc
@@ -0,0 +1,34 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/offline_pages/background/offliner_policy_utils.h"
+
+#include "components/offline_pages/background/offliner_policy.h"
+#include "components/offline_pages/background/save_page_request.h"
+
+namespace offline_pages {
+
+// static function to check request expiration or cleanup status.
+OfflinerPolicyUtils::RequestExpirationStatus
+OfflinerPolicyUtils::CheckRequestExpirationStatus(
+ const SavePageRequest* request,
+ const OfflinerPolicy* policy) {
+ DCHECK(request);
+ DCHECK(policy);
+
+ if (base::Time::Now() - request->creation_time() >=
+ base::TimeDelta::FromSeconds(
+ policy->GetRequestExpirationTimeInSeconds())) {
+ return RequestExpirationStatus::EXPIRED;
+ }
+ if (request->started_attempt_count() >= policy->GetMaxStartedTries())
+ return RequestExpirationStatus::START_COUNT_EXCEEDED;
+
+ if (request->completed_attempt_count() >= policy->GetMaxCompletedTries())
+ return RequestExpirationStatus::COMPLETION_COUNT_EXCEEDED;
+
+ return RequestExpirationStatus::VALID;
+}
+
+} // namespace offline_pages
« no previous file with comments | « components/offline_pages/background/offliner_policy_utils.h ('k') | components/offline_pages/background/pick_request_task.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698