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

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: CR fixes per DougArnett and FGorski. Also gets rid of status. 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 5876d8386d79b7c3834f6cf9b7d72bd22f8c38cd..7165c436f5ba836cea4ac6c5921ecfd7d5e73daa 100644
--- a/components/offline_pages/background/request_coordinator.cc
+++ b/components/offline_pages/background/request_coordinator.cc
@@ -69,6 +69,34 @@ 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,
+ QueuedRequestCallback callback,
+ RequestQueue::GetRequestsResult result,
+ const std::vector<SavePageRequest>& requests) {
+ std::vector<ClientId> found_requests;
fgorski 2016/08/03 03:13:15 Consider renaming to client_ids.
Pete Williamson 2016/08/03 20:13:44 Done.
+
+ // TODO(petewil): Is find_if better that a for loop here?
fgorski 2016/08/03 03:13:15 no, it would be incorrect, because: find_if return
Pete Williamson 2016/08/03 20:13:44 Acknowledged.
+ for (auto iter = requests.begin(); iter != requests.end(); ++iter) {
+ if (client_namespace == iter->client_id().name_space) {
fgorski 2016/08/03 03:13:15 nit: remove {}
Pete Williamson 2016/08/03 20:13:44 Done.
+ found_requests.push_back(iter->client_id());
+ }
+ }
+
+ callback.Run(found_requests);
+}
void RequestCoordinator::AddRequestResultCallback(
RequestQueue::AddRequestResult result,

Powered by Google App Engine
This is Rietveld 408576698