| 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/save_page_request.h" |
| 6 |
| 7 namespace offline_pages { |
| 8 |
| 9 SavePageRequest::SavePageRequest(int64_t request_id, |
| 10 const GURL& url, |
| 11 const base::Time& creation_time) |
| 12 : request_id_(request_id), |
| 13 url_(url), |
| 14 creation_time_(creation_time), |
| 15 activation_time_(creation_time) {} |
| 16 |
| 17 SavePageRequest::SavePageRequest(int64_t request_id, |
| 18 const GURL& url, |
| 19 const base::Time& creation_time, |
| 20 const base::Time& activation_time) |
| 21 : request_id_(request_id), |
| 22 url_(url), |
| 23 creation_time_(creation_time), |
| 24 activation_time_(activation_time) {} |
| 25 |
| 26 SavePageRequest::~SavePageRequest() {} |
| 27 |
| 28 // TODO(fgorski): Introduce policy parameter, once policy is available. |
| 29 SavePageRequest::Status SavePageRequest::GetStatus(const base::Time& now) { |
| 30 if (now < activation_time_) |
| 31 return Status::kNotReady; |
| 32 |
| 33 // TODO(fgorski): enable check once policy available. |
| 34 // if (attempt_count_ >= policy.max_attempt_count) |
| 35 // return Status::kFailed; |
| 36 |
| 37 // TODO(fgorski): enable check once policy available. |
| 38 // if (activation_time_+ policy.page_expiration_interval < now) |
| 39 // return Status::kExpired; |
| 40 |
| 41 if (creation_time_ < last_attempt_time_) |
| 42 return Status::kStarted; |
| 43 |
| 44 return Status::kPending; |
| 45 } |
| 46 |
| 47 void SavePageRequest::MarkAttempStarted(const base::Time& start_time) { |
| 48 DCHECK_LE(activation_time_, start_time); |
| 49 DCHECK_LE(creation_time_, start_time); |
| 50 |
| 51 last_attempt_time_ = start_time; |
| 52 ++attempt_count_; |
| 53 } |
| 54 |
| 55 void SavePageRequest::MarkAttempCompleted() { |
| 56 last_attempt_time_ = base::Time(); |
| 57 } |
| 58 |
| 59 } // namespace offline_pages |
| OLD | NEW |