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 #ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_SAVE_PAGE_REQUEST_H_ | 5 #ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_SAVE_PAGE_REQUEST_H_ |
6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_SAVE_PAGE_REQUEST_H_ | 6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_SAVE_PAGE_REQUEST_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 // when it gets a chance to. | 23 // when it gets a chance to. |
24 STARTED, // The request is currently being processed. | 24 STARTED, // The request is currently being processed. |
25 FAILED, // Page request failed many times and will no longer be | 25 FAILED, // Page request failed many times and will no longer be |
26 // retried. | 26 // retried. |
27 EXPIRED, // Save page request expired without being fulfilled. | 27 EXPIRED, // Save page request expired without being fulfilled. |
28 }; | 28 }; |
29 | 29 |
30 SavePageRequest(int64_t request_id, | 30 SavePageRequest(int64_t request_id, |
31 const GURL& url, | 31 const GURL& url, |
32 const ClientId& client_id, | 32 const ClientId& client_id, |
33 const base::Time& creation_time); | |
34 SavePageRequest(int64_t request_id, | |
35 const GURL& url, | |
36 const ClientId& client_id, | |
37 const base::Time& creation_time, | 33 const base::Time& creation_time, |
38 const base::Time& activation_time); | 34 const bool user_requested); |
| 35 SavePageRequest(int64_t request_id, |
| 36 const GURL& url, |
| 37 const ClientId& client_id, |
| 38 const base::Time& creation_time, |
| 39 const base::Time& activation_time, |
| 40 const bool user_requested); |
39 SavePageRequest(const SavePageRequest& other); | 41 SavePageRequest(const SavePageRequest& other); |
40 ~SavePageRequest(); | 42 ~SavePageRequest(); |
41 | 43 |
42 // Status of this request. | 44 // Status of this request. |
43 Status GetStatus(const base::Time& now) const; | 45 Status GetStatus(const base::Time& now) const; |
44 | 46 |
45 // Updates the |last_attempt_time_| and increments |attempt_count_|. | 47 // Updates the |last_attempt_time_| and increments |attempt_count_|. |
46 void MarkAttemptStarted(const base::Time& start_time); | 48 void MarkAttemptStarted(const base::Time& start_time); |
47 | 49 |
48 // Marks attempt as completed and clears |last_attempt_time_|. | 50 // Marks attempt as completed and clears |last_attempt_time_|. |
(...skipping 12 matching lines...) Expand all Loading... |
61 int64_t attempt_count() const { return attempt_count_; } | 63 int64_t attempt_count() const { return attempt_count_; } |
62 void set_attempt_count(int64_t attempt_count) { | 64 void set_attempt_count(int64_t attempt_count) { |
63 attempt_count_ = attempt_count; | 65 attempt_count_ = attempt_count; |
64 } | 66 } |
65 | 67 |
66 const base::Time& last_attempt_time() const { return last_attempt_time_; } | 68 const base::Time& last_attempt_time() const { return last_attempt_time_; } |
67 void set_last_attempt_time(const base::Time& last_attempt_time) { | 69 void set_last_attempt_time(const base::Time& last_attempt_time) { |
68 last_attempt_time_ = last_attempt_time; | 70 last_attempt_time_ = last_attempt_time; |
69 } | 71 } |
70 | 72 |
| 73 bool user_requested() const { return user_requested_; } |
| 74 |
| 75 void set_user_requested(bool user_requested) { |
| 76 user_requested_ = user_requested; |
| 77 } |
| 78 |
71 private: | 79 private: |
72 // ID of this request. | 80 // ID of this request. |
73 int64_t request_id_; | 81 int64_t request_id_; |
74 | 82 |
75 // Online URL of a page to be offlined. | 83 // Online URL of a page to be offlined. |
76 GURL url_; | 84 GURL url_; |
77 | 85 |
78 // Client ID related to the request. Contains namespace and ID assigned by the | 86 // Client ID related to the request. Contains namespace and ID assigned by the |
79 // requester. | 87 // requester. |
80 ClientId client_id_; | 88 ClientId client_id_; |
81 | 89 |
82 // Time when this request was created. (Alternative 2). | 90 // Time when this request was created. (Alternative 2). |
83 base::Time creation_time_; | 91 base::Time creation_time_; |
84 | 92 |
85 // Time when this request will become active. | 93 // Time when this request will become active. |
86 base::Time activation_time_; | 94 base::Time activation_time_; |
87 | 95 |
88 // Number of attempts made to get the page. | 96 // Number of attempts made to get the page. |
89 int attempt_count_; | 97 int attempt_count_; |
90 | 98 |
91 // Timestamp of the last request starting. | 99 // Timestamp of the last request starting. |
92 base::Time last_attempt_time_; | 100 base::Time last_attempt_time_; |
| 101 |
| 102 // Whether the user specifically requested this page (as opposed to a client |
| 103 // like AGSA or Now.) |
| 104 bool user_requested_; |
93 }; | 105 }; |
94 | 106 |
95 } // namespace offline_pages | 107 } // namespace offline_pages |
96 | 108 |
97 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_SAVE_PAGE_REQUEST_H_ | 109 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_SAVE_PAGE_REQUEST_H_ |
OLD | NEW |