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

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

Issue 2064793003: Remove old requests from queue, start new requests if any, add test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unit test Created 4 years, 6 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
« no previous file with comments | « no previous file | components/offline_pages/background/request_coordinator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..dddcca8d49568d62a029e441d1d5e19d92b83500 100644
--- a/components/offline_pages/background/request_coordinator.h
+++ b/components/offline_pages/background/request_coordinator.h
@@ -55,6 +55,11 @@ class RequestCoordinator : public KeyedService {
// is stopped or complete.
void StopProcessing();
+ // 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 +75,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,9 +85,15 @@ class RequestCoordinator : public KeyedService {
void SendRequestToOffliner(const SavePageRequest& request);
+ // Called by the offliner when an offlining request is completed. (and by
+ // tests).
void OfflinerDoneCallback(const SavePageRequest& request,
Offliner::RequestStatus status);
+ void TryNextRequest();
+
+ friend class RequestCoordinatorTest;
+
// RequestCoordinator takes over ownership of the policy
std::unique_ptr<OfflinerPolicy> policy_;
// OfflinerFactory. Used to create offline pages. Owned.
@@ -93,6 +106,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_;
« no previous file with comments | « no previous file | components/offline_pages/background/request_coordinator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698