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

Unified Diff: components/offline_pages/core/background/request_coordinator.h

Issue 2775223006: [Offline Pages] Improve RequestCoordinator state tracking. (Closed)
Patch Set: comments. Created 3 years, 9 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/core/background/request_coordinator.h
diff --git a/components/offline_pages/core/background/request_coordinator.h b/components/offline_pages/core/background/request_coordinator.h
index 30ac8eb248a3b26754bf78c5c2888efd408ee2cd..8cc3370d47f639496173dc16f7159bd0be905acc 100644
--- a/components/offline_pages/core/background/request_coordinator.h
+++ b/components/offline_pages/core/background/request_coordinator.h
@@ -62,6 +62,12 @@ class RequestCoordinator : public KeyedService,
DISABLED_FOR_OFFLINER,
};
+ enum class RequestCoordinatorState {
+ IDLE,
+ PICKING,
+ OFFLINING,
+ };
+
// Describes the parameters to control how to save a page when system
// conditions allow.
struct SavePageLaterParams {
@@ -204,11 +210,8 @@ class RequestCoordinator : public KeyedService,
return last_offlining_status_;
}
- bool is_busy() { return is_busy_; }
-
- // Returns whether processing is starting (before it is decided to actually
- // process a request (is_busy()) at this time or not.
- bool is_starting() { return is_starting_; }
+ // Return the state of the request coordinator.
+ RequestCoordinatorState state() { return state_; }
// Tracks whether the last offlining attempt got canceled. This is reset by
// the next call to start processing.
@@ -337,7 +340,8 @@ class RequestCoordinator : public KeyedService,
Offliner::RequestStatus stop_status);
// Marks attempt on the request and sends it to offliner in continuation.
- void SendRequestToOffliner(const SavePageRequest& request);
+ // If it fails to send request to offliner, return false.
+ bool SendRequestToOffliner(const SavePageRequest& request);
// Continuation of |SendRequestToOffliner| after the request is marked as
// started.
@@ -406,13 +410,8 @@ class RequestCoordinator : public KeyedService,
// Cached value of whether low end device. Overwritable for testing.
bool is_low_end_device_;
- // The offliner can only handle one request at a time - if the offliner is
- // busy, prevent other requests. This flag marks whether the offliner is in
- // use.
- bool is_busy_;
- // There is more than one path to start processing so this flag is used
- // to avoid race conditions before is_busy_ is established.
- bool is_starting_;
+ // Current state of the request coordinator.
+ RequestCoordinatorState state_;
// Identifies the type of current processing window or if processing stopped.
ProcessingWindowState processing_state_;
// True if we should use the test device conditions instead of actual

Powered by Google App Engine
This is Rietveld 408576698