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

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

Issue 2066593003: Add a general purpose facility for letting background tasks wait until (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
Index: components/offline_pages/background/request_coordinator.cc
diff --git a/components/offline_pages/background/request_coordinator.cc b/components/offline_pages/background/request_coordinator.cc
index 0a0ebdb23c01345f3a6a8547ce4dd4213c6f98de..532725cc87cf3055f6e3f679c2b2e45fbb4b0206 100644
--- a/components/offline_pages/background/request_coordinator.cc
+++ b/components/offline_pages/background/request_coordinator.cc
@@ -69,11 +69,6 @@ void RequestCoordinator::AddRequestResultCallback(
}
void RequestCoordinator::RequestPicked(const SavePageRequest& request) {
- Scheduler::TriggerCondition conditions;
-
- // Ensure that the scheduler has actively scheduled a task.
- scheduler_->Schedule(conditions);
-
// Send the request on to the offliner.
SendRequestToOffliner(request);
}
@@ -84,7 +79,8 @@ void RequestCoordinator::RequestQueueEmpty() {
}
bool RequestCoordinator::StartProcessing(
- const base::Callback<void(bool)>& callback) {
+ base::Callback<void(bool)> callback) {
+ scheduler_callback_ = callback;
// TODO(petewil): Check existing conditions (should be passed down from
// BackgroundTask)
@@ -128,6 +124,9 @@ void RequestCoordinator::OfflinerDoneCallback(const SavePageRequest& request,
// to the scheduler if we are out of time.
// TODO(petewil): If the request succeeded, remove it from the Queue.
+
+ // Return control to the scheduler when there is no more to do.
+ scheduler_callback_.Run(status == Offliner::RequestStatus::SAVED);
}
} // namespace offline_pages

Powered by Google App Engine
This is Rietveld 408576698