ScriptPromise ServiceWorkerRegistrationNotifications::getNotifications(ScriptState* scriptState, ServiceWorkerRegistration& serviceWorkerRegistration, const GetNotificationOptions& options)
{
    RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scriptState);
    ScriptPromise promise = resolver->promise();

    WebNotificationGetCallbacks* callbacks = new CallbackPromiseAdapter<NotificationArray, void>(resolver);

    WebNotificationManager* notificationManager = Platform::current()->notificationManager();
    ASSERT(notificationManager);

    notificationManager->getNotifications(options.tag(), serviceWorkerRegistration.webRegistration(), callbacks);
    return promise;
}
Ejemplo n.º 2
0
ScriptPromise ServiceWorkerRegistrationNotifications::getNotifications(
    ScriptState* scriptState,
    ServiceWorkerRegistration& registration,
    const GetNotificationOptions& options) {
  ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
  ScriptPromise promise = resolver->promise();

  auto callbacks =
      WTF::makeUnique<CallbackPromiseAdapter<NotificationArray, void>>(
          resolver);

  WebNotificationManager* notificationManager =
      Platform::current()->notificationManager();
  DCHECK(notificationManager);

  notificationManager->getNotifications(
      options.tag(), registration.webRegistration(), std::move(callbacks));
  return promise;
}