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

Unified Diff: components/offline_pages/background/save_page_request.h

Issue 2218403002: Change database scheme - add state and start tracking (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Stop clearing last request time 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 side-by-side diff with in-line comments
Download patch
Index: components/offline_pages/background/save_page_request.h
diff --git a/components/offline_pages/background/save_page_request.h b/components/offline_pages/background/save_page_request.h
index b83b9b5c4ec6b69d9eddfda6e4440d7ab90624f7..9ddff04c47a17ad5e392c79c510f4ab4d9d5df0a 100644
--- a/components/offline_pages/background/save_page_request.h
+++ b/components/offline_pages/background/save_page_request.h
@@ -16,6 +16,12 @@ namespace offline_pages {
// Class representing a request to save page.
class SavePageRequest {
public:
+ enum class RequestState {
+ AVAILABLE = 0, // Request can be scheduled when preconditions are met.
+ PAUSED = 1, // Request is not available until it is unpaused
+ PRERENDERING = 2, // Request is active in the pre-renderer
+ };
+
SavePageRequest(int64_t request_id,
const GURL& url,
const ClientId& client_id,
@@ -40,19 +46,31 @@ class SavePageRequest {
// and decrements |attempt_count_|.
void MarkAttemptAborted();
+ // Mark the attempt as paused. It is not available for future prerendering
+ // until it has been explicitly unpaused.
+ void MarkAttemptPaused();
+
int64_t request_id() const { return request_id_; }
const GURL& url() const { return url_; }
const ClientId& client_id() const { return client_id_; }
+ RequestState request_state() const { return state_; }
+ void set_request_state(RequestState new_state) { state_ = new_state; }
+
const base::Time& creation_time() const { return creation_time_; }
const base::Time& activation_time() const { return activation_time_; }
- int64_t attempt_count() const { return attempt_count_; }
- void set_attempt_count(int64_t attempt_count) {
- attempt_count_ = attempt_count;
+ int64_t started_attempt_count() const { return started_attempt_count_; }
+ void set_started_attempt_count(int64_t started_attempt_count) {
+ started_attempt_count_ = started_attempt_count;
+ }
+
+ int64_t completed_attempt_count() const { return completed_attempt_count_; }
+ void set_completed_attempt_count(int64_t completed_attempt_count) {
+ completed_attempt_count_ = completed_attempt_count;
}
const base::Time& last_attempt_time() const { return last_attempt_time_; }
@@ -83,8 +101,12 @@ class SavePageRequest {
// Time when this request will become active.
base::Time activation_time_;
- // Number of attempts made to get the page.
- int attempt_count_;
+ // Number of attempts started to get the page. This may be different than the
+ // number of attempts completed because we could crash.
+ int started_attempt_count_;
+
+ // Number of attempts we actually completed to get the page.
+ int completed_attempt_count_;
// Timestamp of the last request starting.
base::Time last_attempt_time_;
@@ -92,6 +114,9 @@ class SavePageRequest {
// Whether the user specifically requested this page (as opposed to a client
// like AGSA or Now.)
bool user_requested_;
+
+ // The current state of this request
+ RequestState state_;
};
} // namespace offline_pages

Powered by Google App Engine
This is Rietveld 408576698