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

Side by Side Diff: components/offline_pages/background/save_page_request.cc

Issue 2209993002: Remove the GetStatus() call from SavePageRequest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Undo the fix for closure since we put status back. Created 4 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/offline_pages/background/save_page_request.h" 5 #include "components/offline_pages/background/save_page_request.h"
6 6
7 namespace offline_pages { 7 namespace offline_pages {
8 8
9 SavePageRequest::SavePageRequest(int64_t request_id, 9 SavePageRequest::SavePageRequest(int64_t request_id,
10 const GURL& url, 10 const GURL& url,
(...skipping 27 matching lines...) Expand all
38 url_(other.url_), 38 url_(other.url_),
39 client_id_(other.client_id_), 39 client_id_(other.client_id_),
40 creation_time_(other.creation_time_), 40 creation_time_(other.creation_time_),
41 activation_time_(other.activation_time_), 41 activation_time_(other.activation_time_),
42 attempt_count_(other.attempt_count_), 42 attempt_count_(other.attempt_count_),
43 last_attempt_time_(other.last_attempt_time_), 43 last_attempt_time_(other.last_attempt_time_),
44 user_requested_(other.user_requested_) {} 44 user_requested_(other.user_requested_) {}
45 45
46 SavePageRequest::~SavePageRequest() {} 46 SavePageRequest::~SavePageRequest() {}
47 47
48 // TODO(fgorski): Introduce policy parameter, once policy is available.
49 SavePageRequest::Status SavePageRequest::GetStatus(
50 const base::Time& now) const {
51 if (now < activation_time_)
52 return Status::NOT_READY;
53
54 // TODO(fgorski): enable check once policy available.
55 // if (attempt_count_ >= policy.max_attempt_count)
56 // return Status::FAILED;
57
58 // TODO(fgorski): enable check once policy available.
59 // if (activation_time_+ policy.page_expiration_interval < now)
60 // return Status::EXPIRED;
61
62 if (creation_time_ < last_attempt_time_)
63 return Status::STARTED;
64
65 return Status::PENDING;
66 }
67
68 void SavePageRequest::MarkAttemptStarted(const base::Time& start_time) { 48 void SavePageRequest::MarkAttemptStarted(const base::Time& start_time) {
69 DCHECK_LE(activation_time_, start_time); 49 DCHECK_LE(activation_time_, start_time);
70 // TODO(fgorski): As part of introducing policy in GetStatus, we can make a 50 // TODO(fgorski): As part of introducing policy in GetStatus, we can make a
71 // check here to ensure we only start tasks in status pending, and bail out in 51 // check here to ensure we only start tasks in status pending, and bail out in
72 // other cases. 52 // other cases.
73 last_attempt_time_ = start_time; 53 last_attempt_time_ = start_time;
74 ++attempt_count_; 54 ++attempt_count_;
75 } 55 }
76 56
77 void SavePageRequest::MarkAttemptCompleted() { 57 void SavePageRequest::MarkAttemptCompleted() {
78 last_attempt_time_ = base::Time(); 58 last_attempt_time_ = base::Time();
79 } 59 }
80 60
81 } // namespace offline_pages 61 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698