Chromium Code Reviews| 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..f97097eb451db8304f7b2049512c2a22c3d8d856 |
| --- /dev/null |
| +++ b/components/offline_pages/background/offliner_policy_utils.cc |
| @@ -0,0 +1,30 @@ |
| +// 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(SavePageRequest* request, |
| + OfflinerPolicy* policy) { |
|
fgorski
2016/12/05 21:05:37
Could you dcheck parameters here?
Also, is there
Pete Williamson
2016/12/06 00:25:38
Done.
|
| + 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 |