| 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" |
| 11 #include "components/offline_pages/offline_page_item.h" | 11 #include "components/offline_pages/offline_page_item.h" |
| 12 #include "url/gurl.h" | 12 #include "url/gurl.h" |
| 13 | 13 |
| 14 namespace offline_pages { | 14 namespace offline_pages { |
| 15 | 15 |
| 16 // Class representing a request to save page. | 16 // Class representing a request to save page. |
| 17 class SavePageRequest { | 17 class SavePageRequest { |
| 18 public: | 18 public: |
| 19 enum class Status { | |
| 20 NOT_READY, // Component requested a page be saved, but not until | |
| 21 // |activation_time_|. | |
| 22 PENDING, // Page request is pending, and coordinator can attempt it | |
| 23 // when it gets a chance to. | |
| 24 STARTED, // The request is currently being processed. | |
| 25 FAILED, // Page request failed many times and will no longer be | |
| 26 // retried. | |
| 27 EXPIRED, // Save page request expired without being fulfilled. | |
| 28 }; | |
| 29 | |
| 30 SavePageRequest(int64_t request_id, | 19 SavePageRequest(int64_t request_id, |
| 31 const GURL& url, | 20 const GURL& url, |
| 32 const ClientId& client_id, | 21 const ClientId& client_id, |
| 33 const base::Time& creation_time, | 22 const base::Time& creation_time, |
| 34 const bool user_requested); | 23 const bool user_requested); |
| 35 SavePageRequest(int64_t request_id, | 24 SavePageRequest(int64_t request_id, |
| 36 const GURL& url, | 25 const GURL& url, |
| 37 const ClientId& client_id, | 26 const ClientId& client_id, |
| 38 const base::Time& creation_time, | 27 const base::Time& creation_time, |
| 39 const base::Time& activation_time, | 28 const base::Time& activation_time, |
| 40 const bool user_requested); | 29 const bool user_requested); |
| 41 SavePageRequest(const SavePageRequest& other); | 30 SavePageRequest(const SavePageRequest& other); |
| 42 ~SavePageRequest(); | 31 ~SavePageRequest(); |
| 43 | 32 |
| 44 // Status of this request. | |
| 45 Status GetStatus(const base::Time& now) const; | |
| 46 | |
| 47 // Updates the |last_attempt_time_| and increments |attempt_count_|. | 33 // Updates the |last_attempt_time_| and increments |attempt_count_|. |
| 48 void MarkAttemptStarted(const base::Time& start_time); | 34 void MarkAttemptStarted(const base::Time& start_time); |
| 49 | 35 |
| 50 // Marks attempt as completed and clears |last_attempt_time_|. | 36 // Marks attempt as completed and clears |last_attempt_time_|. |
| 51 void MarkAttemptCompleted(); | 37 void MarkAttemptCompleted(); |
| 52 | 38 |
| 53 int64_t request_id() const { return request_id_; } | 39 int64_t request_id() const { return request_id_; } |
| 54 | 40 |
| 55 const GURL& url() const { return url_; } | 41 const GURL& url() const { return url_; } |
| 56 | 42 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 base::Time last_attempt_time_; | 86 base::Time last_attempt_time_; |
| 101 | 87 |
| 102 // Whether the user specifically requested this page (as opposed to a client | 88 // Whether the user specifically requested this page (as opposed to a client |
| 103 // like AGSA or Now.) | 89 // like AGSA or Now.) |
| 104 bool user_requested_; | 90 bool user_requested_; |
| 105 }; | 91 }; |
| 106 | 92 |
| 107 } // namespace offline_pages | 93 } // namespace offline_pages |
| 108 | 94 |
| 109 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_SAVE_PAGE_REQUEST_H_ | 95 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_SAVE_PAGE_REQUEST_H_ |
| OLD | NEW |