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

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

Issue 1932953002: [Offline pages] Empty RequestQueue and SavePageRequest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing nits from Pete Created 4 years, 7 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
(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 ClientId& client_id,
12 const base::Time& creation_time)
13 : request_id_(request_id),
14 url_(url),
15 client_id_(client_id),
16 creation_time_(creation_time),
17 activation_time_(creation_time),
18 attempt_count_(0) {}
19
20 SavePageRequest::SavePageRequest(int64_t request_id,
21 const GURL& url,
22 const ClientId& client_id,
23 const base::Time& creation_time,
24 const base::Time& activation_time)
25 : request_id_(request_id),
26 url_(url),
27 client_id_(client_id),
28 creation_time_(creation_time),
29 activation_time_(activation_time),
30 attempt_count_(0) {}
31
32 SavePageRequest::~SavePageRequest() {}
33
34 // TODO(fgorski): Introduce policy parameter, once policy is available.
35 SavePageRequest::Status SavePageRequest::GetStatus(
36 const base::Time& now) const {
37 if (now < activation_time_)
38 return Status::kNotReady;
39
40 // TODO(fgorski): enable check once policy available.
41 // if (attempt_count_ >= policy.max_attempt_count)
42 // return Status::kFailed;
43
44 // TODO(fgorski): enable check once policy available.
45 // if (activation_time_+ policy.page_expiration_interval < now)
46 // return Status::kExpired;
47
48 if (creation_time_ < last_attempt_time_)
49 return Status::kStarted;
50
51 return Status::kPending;
52 }
53
54 void SavePageRequest::MarkAttemptStarted(const base::Time& start_time) {
55 DCHECK_LE(activation_time_, start_time);
56 // TODO(fgorski): As part of introducing policy in GetStatus, we can make a
57 // check here to ensure we only start tasks in status pending, and bail out in
58 // other cases.
59 last_attempt_time_ = start_time;
60 ++attempt_count_;
61 }
62
63 void SavePageRequest::MarkAttemptCompleted() {
64 last_attempt_time_ = base::Time();
65 }
66
67 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698