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

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

Issue 2202113002: API to provide status of save page reqeusts to API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean up naming Created 4 years, 4 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 f8d9eba9c5606f961f0ba7a06ecdb1bac51475d0..b32cfa2f56f4a4862b446f86eff27bc38fa75a09 100644
--- a/components/offline_pages/background/request_coordinator.cc
+++ b/components/offline_pages/background/request_coordinator.cc
@@ -69,6 +69,32 @@ bool RequestCoordinator::SavePageLater(
weak_ptr_factory_.GetWeakPtr()));
return true;
}
+void RequestCoordinator::GetQueuedRequests(
+ const std::string& client_namespace,
+ const QueuedRequestCallback& callback) {
+ // Get all matching requests from the request queue, send them to our
+ // callback. We bind the namespace and callback to the front of the callback
+ // param set.
+ queue_->GetRequests(base::Bind(&RequestCoordinator::GetQueuedRequestsCallback,
+ weak_ptr_factory_.GetWeakPtr(),
+ client_namespace, callback));
+}
+
+// For each request matching the client_namespace, return the ClientId.
+void RequestCoordinator::GetQueuedRequestsCallback(
+ const std::string& client_namespace,
+ const QueuedRequestCallback& callback,
+ RequestQueue::GetRequestsResult result,
+ const std::vector<SavePageRequest>& requests) {
+ std::vector<ClientId> client_ids;
+
+ for (const auto& request : requests) {
+ if (client_namespace == request.client_id().name_space)
+ client_ids.push_back(request.client_id());
+ }
+
+ callback.Run(client_ids);
+}
void RequestCoordinator::RemoveRequests(
const std::vector<ClientId>& client_ids) {

Powered by Google App Engine
This is Rietveld 408576698