Chromium Code Reviews| Index: components/offline_pages/background/request_coordinator.h |
| diff --git a/components/offline_pages/background/request_coordinator.h b/components/offline_pages/background/request_coordinator.h |
| index a6001a04b6e0d9991bbf1a17ff0dcef48122aa8e..033488d57227c93472da575e008ca0f0a4d121af 100644 |
| --- a/components/offline_pages/background/request_coordinator.h |
| +++ b/components/offline_pages/background/request_coordinator.h |
| @@ -47,7 +47,7 @@ class RequestCoordinator : public KeyedService { |
| // Starts processing of one or more queued save page later requests. |
| // Returns whether processing was started and that caller should expect |
| // a callback. If processing was already active, returns false. |
| - bool StartProcessing(const base::Callback<void(bool)>& callback); |
| + bool StartProcessing(const base::Callback<void(bool)> callback); |
| // Stops the current request processing if active. This is a way for |
| // caller to abort processing; otherwise, processing will complete on |
| @@ -55,6 +55,16 @@ class RequestCoordinator : public KeyedService { |
| // is stopped or complete. |
| void StopProcessing(); |
| + // Called by the offliner when an offlining request is completed. (and by |
| + // tests). |
| + void OfflinerDoneCallback(const SavePageRequest& request, |
|
dewittj
2016/06/14 16:16:36
nit: make this private and make the test harness a
Pete Williamson
2016/06/14 21:03:14
Done.
|
| + Offliner::RequestStatus status); |
| + |
| + // A way for tests to set the callback in use when an operation is over. |
| + void SetProcessingCallbackForTest(const base::Callback<void(bool)> callback) { |
| + scheduler_callback_ = callback; |
| + } |
| + |
| // Returns the request queue used for requests. Coordinator keeps ownership. |
| RequestQueue* queue() { return queue_.get(); } |
| @@ -70,6 +80,8 @@ class RequestCoordinator : public KeyedService { |
| void AddRequestResultCallback(RequestQueue::AddRequestResult result, |
| const SavePageRequest& request); |
| + void UpdateRequestCallback(RequestQueue::UpdateRequestResult result); |
| + |
| // Callback from the request picker when it has chosen our next request. |
| void RequestPicked(const SavePageRequest& request); |
| @@ -78,8 +90,7 @@ class RequestCoordinator : public KeyedService { |
| void SendRequestToOffliner(const SavePageRequest& request); |
| - void OfflinerDoneCallback(const SavePageRequest& request, |
| - Offliner::RequestStatus status); |
| + void TryNextRequest(); |
| // RequestCoordinator takes over ownership of the policy |
| std::unique_ptr<OfflinerPolicy> policy_; |
| @@ -93,6 +104,8 @@ class RequestCoordinator : public KeyedService { |
| Offliner::RequestStatus last_offlining_status_; |
| // Class to choose which request to schedule next |
| std::unique_ptr<RequestPicker> picker_; |
| + // Calling this returns to the scheduler across the JNI bridge. |
| + base::Callback<void(bool)> scheduler_callback_; |
| // Allows us to pass a weak pointer to callbacks. |
| base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_; |