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

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

Issue 2020833002: Add the request picker and a unit test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR feedback per Dimich and DougArnett Created 4 years, 7 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/request_coordinator.h
diff --git a/components/offline_pages/background/request_coordinator.h b/components/offline_pages/background/request_coordinator.h
index 77c24948a2effb2643dec93169645e9d977fee24..5f9f9d4826e3e065945db3dfbcbdaec61cf22398 100644
--- a/components/offline_pages/background/request_coordinator.h
+++ b/components/offline_pages/background/request_coordinator.h
@@ -21,16 +21,18 @@ struct ClientId;
class OfflinerPolicy;
class OfflinerFactory;
class Offliner;
+class RequestPicker;
class SavePageRequest;
class Scheduler;
// Coordinates queueing and processing save page later requests.
-class RequestCoordinator :
- public KeyedService,
- public base::SupportsWeakPtr<RequestCoordinator> {
+class RequestCoordinator : public KeyedService {
public:
// Callback to report when the processing of a triggered task is complete.
typedef base::Callback<void()> ProcessingDoneCallback;
+ typedef base::Callback<void(const SavePageRequest& request)>
+ RequestPickedCallback;
+ typedef base::Callback<void()> RequestQueueEmptyCallback;
RequestCoordinator(std::unique_ptr<OfflinerPolicy> policy,
std::unique_ptr<OfflinerFactory> factory,
@@ -68,6 +70,12 @@ class RequestCoordinator :
void AddRequestResultCallback(RequestQueue::AddRequestResult result,
const SavePageRequest& request);
+ // Callback from the request picker when it has chosen our next request.
+ void RequestPicked(const SavePageRequest& request);
+
+ // Callback from the request picker when no more requests are in the queue.
+ void RequestQueueEmpty();
+
void SendRequestToOffliner(const SavePageRequest& request);
void OfflinerDoneCallback(const SavePageRequest& request,
@@ -83,6 +91,10 @@ class RequestCoordinator :
std::unique_ptr<Scheduler> scheduler_;
// Status of the most recent offlining.
Offliner::RequestStatus last_offlining_status_;
+ // Class to choose which request to schedule next
+ std::unique_ptr<RequestPicker> picker_;
+ // Allows us to pass a weak pointer to callbacks.
+ base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(RequestCoordinator);
};
« no previous file with comments | « components/offline_pages/background/BUILD.gn ('k') | components/offline_pages/background/request_coordinator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698