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

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

Issue 2400393002: Set up a backup schedule request if we have deferred requests. (Closed)
Patch Set: Created 4 years, 2 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 9bb828867fd07cb7d98df95eeb2b81c87fec3d45..092d608799793ffb6732476403decf05fc5a5ae4 100644
--- a/components/offline_pages/background/request_coordinator.cc
+++ b/components/offline_pages/background/request_coordinator.cc
@@ -25,6 +25,7 @@ namespace offline_pages {
namespace {
const bool kUserRequest = true;
+const int kDisabledTaskRecheckSeconds = 5 * 60;
Dmitry Titov 2016/10/10 17:29:45 I think this needs to be a much shorter interval.
Pete Williamson 2016/10/10 19:45:17 Done.
// Records the final request status UMA for an offlining request. This should
// only be called once per Offliner::LoadAndSave request.
@@ -460,8 +461,15 @@ void RequestCoordinator::RequestNotPicked(
// Clear the outstanding "safety" task in the scheduler.
scheduler_->Unschedule();
- if (non_user_requested_tasks_remaining)
+ // If disabled tasks remain, post a new safety task for 5 min from now.
+ if (disabled_requests_.size() > 0) {
+ scheduler_->BackupSchedule(GetTriggerConditions(kUserRequest),
+ kDisabledTaskRecheckSeconds);
+ } else if (non_user_requested_tasks_remaining) {
+ // If we don't have any of those, check for non-user-requested tasks.
scheduler_->Schedule(GetTriggerConditions(!kUserRequest));
+ }
+
// Let the scheduler know we are done processing.
scheduler_callback_.Run(true);
}
@@ -583,9 +591,13 @@ void RequestCoordinator::OfflinerDoneCallback(const SavePageRequest& request,
void RequestCoordinator::EnableForOffliner(int64_t request_id) {
disabled_requests_.erase(request_id);
+ // If we are not busy, start processing right away.
+ StartProcessingIfConnected();
}
-void RequestCoordinator::MarkRequestCompleted(int64_t request_id) {}
+void RequestCoordinator::MarkRequestCompleted(int64_t request_id) {
+ // TODO: Remove the request, but send out SUCCEEDED instead of removed.
+}
const Scheduler::TriggerConditions RequestCoordinator::GetTriggerConditions(
const bool user_requested) {

Powered by Google App Engine
This is Rietveld 408576698