OLD | NEW |
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, |
11 const ClientId& client_id, | 11 const ClientId& client_id, |
12 const base::Time& creation_time) | 12 const base::Time& creation_time, |
| 13 const bool was_user_requested) |
13 : request_id_(request_id), | 14 : request_id_(request_id), |
14 url_(url), | 15 url_(url), |
15 client_id_(client_id), | 16 client_id_(client_id), |
16 creation_time_(creation_time), | 17 creation_time_(creation_time), |
17 activation_time_(creation_time), | 18 activation_time_(creation_time), |
18 attempt_count_(0) {} | 19 attempt_count_(0), |
| 20 user_requested_(was_user_requested) {} |
19 | 21 |
20 SavePageRequest::SavePageRequest(int64_t request_id, | 22 SavePageRequest::SavePageRequest(int64_t request_id, |
21 const GURL& url, | 23 const GURL& url, |
22 const ClientId& client_id, | 24 const ClientId& client_id, |
23 const base::Time& creation_time, | 25 const base::Time& creation_time, |
24 const base::Time& activation_time) | 26 const base::Time& activation_time, |
| 27 const bool user_requested) |
25 : request_id_(request_id), | 28 : request_id_(request_id), |
26 url_(url), | 29 url_(url), |
27 client_id_(client_id), | 30 client_id_(client_id), |
28 creation_time_(creation_time), | 31 creation_time_(creation_time), |
29 activation_time_(activation_time), | 32 activation_time_(activation_time), |
30 attempt_count_(0) {} | 33 attempt_count_(0), |
| 34 user_requested_(user_requested) {} |
31 | 35 |
32 SavePageRequest::SavePageRequest(const SavePageRequest& other) | 36 SavePageRequest::SavePageRequest(const SavePageRequest& other) |
33 : request_id_(other.request_id_), | 37 : request_id_(other.request_id_), |
34 url_(other.url_), | 38 url_(other.url_), |
35 client_id_(other.client_id_), | 39 client_id_(other.client_id_), |
36 creation_time_(other.creation_time_), | 40 creation_time_(other.creation_time_), |
37 activation_time_(other.activation_time_), | 41 activation_time_(other.activation_time_), |
38 attempt_count_(other.attempt_count_), | 42 attempt_count_(other.attempt_count_), |
39 last_attempt_time_(other.last_attempt_time_) {} | 43 last_attempt_time_(other.last_attempt_time_), |
| 44 user_requested_(other.user_requested_) {} |
40 | 45 |
41 SavePageRequest::~SavePageRequest() {} | 46 SavePageRequest::~SavePageRequest() {} |
42 | 47 |
43 // TODO(fgorski): Introduce policy parameter, once policy is available. | 48 // TODO(fgorski): Introduce policy parameter, once policy is available. |
44 SavePageRequest::Status SavePageRequest::GetStatus( | 49 SavePageRequest::Status SavePageRequest::GetStatus( |
45 const base::Time& now) const { | 50 const base::Time& now) const { |
46 if (now < activation_time_) | 51 if (now < activation_time_) |
47 return Status::NOT_READY; | 52 return Status::NOT_READY; |
48 | 53 |
49 // TODO(fgorski): enable check once policy available. | 54 // TODO(fgorski): enable check once policy available. |
(...skipping 17 matching lines...) Expand all Loading... |
67 // other cases. | 72 // other cases. |
68 last_attempt_time_ = start_time; | 73 last_attempt_time_ = start_time; |
69 ++attempt_count_; | 74 ++attempt_count_; |
70 } | 75 } |
71 | 76 |
72 void SavePageRequest::MarkAttemptCompleted() { | 77 void SavePageRequest::MarkAttemptCompleted() { |
73 last_attempt_time_ = base::Time(); | 78 last_attempt_time_ = base::Time(); |
74 } | 79 } |
75 | 80 |
76 } // namespace offline_pages | 81 } // namespace offline_pages |
OLD | NEW |