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

Unified Diff: content/child/service_worker/service_worker_dispatcher.cc

Issue 2564363002: ServiceWorker: Replace RegistrationCallback and GetRegistrationsCallback with CallbackPromiseAdapter (Closed)
Patch Set: base::MakeUnique 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
« no previous file with comments | « no previous file | content/child/service_worker/web_service_worker_registration_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/service_worker/service_worker_dispatcher.cc
diff --git a/content/child/service_worker/service_worker_dispatcher.cc b/content/child/service_worker/service_worker_dispatcher.cc
index c1934f515c181edec240f2fc7081ef25eac5cdae..d0db7dea5ebd996a36e13bbb8740b23e257dc31e 100644
--- a/content/child/service_worker/service_worker_dispatcher.cc
+++ b/content/child/service_worker/service_worker_dispatcher.cc
@@ -8,6 +8,7 @@
#include <utility>
#include "base/lazy_instance.h"
+#include "base/memory/ptr_util.h"
#include "base/single_thread_task_runner.h"
#include "base/stl_util.h"
#include "base/threading/thread_local.h"
@@ -523,21 +524,15 @@ void ServiceWorkerDispatcher::OnDidGetRegistrations(
if (!callbacks)
return;
- typedef blink::WebVector<blink::WebServiceWorkerRegistration::Handle*>
- WebServiceWorkerRegistrationArray;
- std::unique_ptr<WebServiceWorkerRegistrationArray> registrations(
- new WebServiceWorkerRegistrationArray(infos.size()));
+ using WebServiceWorkerRegistrationHandles =
+ WebServiceWorkerProvider::WebServiceWorkerRegistrationHandles;
+ std::unique_ptr<WebServiceWorkerRegistrationHandles> registrations =
+ base::MakeUnique<WebServiceWorkerRegistrationHandles>(infos.size());
for (size_t i = 0; i < infos.size(); ++i) {
- if (infos[i].handle_id != kInvalidServiceWorkerHandleId) {
- ServiceWorkerRegistrationObjectInfo info(infos[i]);
- ServiceWorkerVersionAttributes attr(attrs[i]);
-
- // WebServiceWorkerGetRegistrationsCallbacks cannot receive an array of
- // std::unique_ptr<WebServiceWorkerRegistration::Handle>, so create leaky
- // handles instead.
- (*registrations)[i] = WebServiceWorkerRegistrationImpl::CreateLeakyHandle(
- GetOrAdoptRegistration(info, attr));
- }
+ if (infos[i].handle_id == kInvalidServiceWorkerHandleId)
+ continue;
+ (*registrations)[i] = WebServiceWorkerRegistrationImpl::CreateHandle(
+ GetOrAdoptRegistration(infos[i], attrs[i]));
}
callbacks->onSuccess(std::move(registrations));
« no previous file with comments | « no previous file | content/child/service_worker/web_service_worker_registration_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698