Chromium Code Reviews| 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..940026224d7fa509fa0ae268ff59e818fb9c396a 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, |
| + STARTING, |
|
Pete Williamson
2017/03/28 00:35:13
PICKING might be more descriptive than STARTING.
romax
2017/03/28 01:09:56
Done.
|
| + 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 |