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

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

Issue 2568613002: Reconcile the request queue on startup. (Closed)
Patch Set: compile fix Created 4 years 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/core/background/request_coordinator.cc
diff --git a/components/offline_pages/core/background/request_coordinator.cc b/components/offline_pages/core/background/request_coordinator.cc
index 346ec0294a13ff8f0f916bd92c041b163888769b..e25b4b09cbe6775adbbc9abb17dededdee596351 100644
--- a/components/offline_pages/core/background/request_coordinator.cc
+++ b/components/offline_pages/core/background/request_coordinator.cc
@@ -184,7 +184,13 @@ RequestCoordinator::RequestCoordinator(
std::unique_ptr<CleanupTaskFactory> cleanup_factory(
new CleanupTaskFactory(policy_.get(), this, &event_logger_));
queue_->SetCleanupFactory(std::move(cleanup_factory));
- // Do a cleanup at startup time.
+ // If we exited with any items left in the OFFLINING state, move them back to
+ // the AVAILABLE state, and update the UI by sending notifications. Do this
+ // before we cleanup, so any requests that are now OFFLINING which have
+ // expired can be legitimate candidates for cleanup.
+ queue_->ReconcileRequests(base::Bind(&RequestCoordinator::ReconcileCallback,
+ weak_ptr_factory_.GetWeakPtr()));
+ // Do a cleanup of expired or over tried requests at startup time.
queue_->CleanupRequestQueue();
}
@@ -466,6 +472,12 @@ void RequestCoordinator::UpdateMultipleRequestsCallback(
StartImmediatelyIfConnected();
}
+void RequestCoordinator::ReconcileCallback(
+ std::unique_ptr<UpdateRequestsResult> result) {
+ for (const auto& request : result->updated_items)
+ NotifyChanged(request);
+}
+
void RequestCoordinator::HandleRemovedRequestsAndCallback(
const RemoveRequestsCallback& callback,
RequestNotifier::BackgroundSavePageResult status,

Powered by Google App Engine
This is Rietveld 408576698