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

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

Issue 2568613002: Reconcile the request queue on startup. (Closed)
Patch Set: 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 79b0de0e78ac7f279eadd8e0ad8689dee9d7cb74..37129079a804f3e01256dee69c2f2811770224bd 100644
--- a/components/offline_pages/core/background/request_coordinator.cc
+++ b/components/offline_pages/core/background/request_coordinator.cc
@@ -184,7 +184,11 @@ 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
fgorski 2016/12/12 17:35:18 I think order between reconcile and clean up makes
Pete Williamson 2016/12/15 18:37:43 Both orders should work fine. I picked this one b
+ // back to the AVAILABLE state, and update the UI by sending notifications.
+ 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 +470,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