Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "components/offline_pages/background/offliner_policy_utils.h" | |
| 6 | |
| 7 #include "components/offline_pages/background/offliner_policy.h" | |
| 8 #include "components/offline_pages/background/save_page_request.h" | |
| 9 | |
| 10 namespace offline_pages { | |
| 11 | |
| 12 // static function to check request expiration or cleanup status. | |
| 13 OfflinerPolicyUtils::RequestExpirationStatus | |
| 14 OfflinerPolicyUtils::CheckRequestExpirationStatus(SavePageRequest* request, | |
| 15 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.
| |
| 16 if (base::Time::Now() - request->creation_time() >= | |
| 17 base::TimeDelta::FromSeconds( | |
| 18 policy->GetRequestExpirationTimeInSeconds())) { | |
| 19 return RequestExpirationStatus::EXPIRED; | |
| 20 } | |
| 21 if (request->started_attempt_count() >= policy->GetMaxStartedTries()) | |
| 22 return RequestExpirationStatus::START_COUNT_EXCEEDED; | |
| 23 | |
| 24 if (request->completed_attempt_count() >= policy->GetMaxCompletedTries()) | |
| 25 return RequestExpirationStatus::COMPLETION_COUNT_EXCEEDED; | |
| 26 | |
| 27 return RequestExpirationStatus::VALID; | |
| 28 } | |
| 29 | |
| 30 } // namespace offline_pages | |
| OLD | NEW |