Chromium Code Reviews| 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, |