| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "modules/notifications/ServiceWorkerRegistrationNotifications.h" | 6 #include "modules/notifications/ServiceWorkerRegistrationNotifications.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
| 9 #include "bindings/core/v8/ExceptionState.h" | 9 #include "bindings/core/v8/ExceptionState.h" |
| 10 #include "bindings/core/v8/ScriptPromiseResolver.h" | 10 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "wtf/OwnPtr.h" | 26 #include "wtf/OwnPtr.h" |
| 27 #include "wtf/PassOwnPtr.h" | 27 #include "wtf/PassOwnPtr.h" |
| 28 | 28 |
| 29 namespace blink { | 29 namespace blink { |
| 30 namespace { | 30 namespace { |
| 31 | 31 |
| 32 // Allows using a CallbackPromiseAdapter with a WebVector to resolve the | 32 // Allows using a CallbackPromiseAdapter with a WebVector to resolve the |
| 33 // getNotifications() promise with a HeapVector owning Notifications. | 33 // getNotifications() promise with a HeapVector owning Notifications. |
| 34 class NotificationArray { | 34 class NotificationArray { |
| 35 public: | 35 public: |
| 36 using WebType = OwnPtr<WebVector<WebPersistentNotificationInfo>>; | 36 using WebType = const WebVector<WebPersistentNotificationInfo>&; |
| 37 | 37 |
| 38 static HeapVector<Member<Notification>> take(ScriptPromiseResolver* resolver
, PassOwnPtr<WebVector<WebPersistentNotificationInfo>> notificationInfos) | 38 static HeapVector<Member<Notification>> take(ScriptPromiseResolver* resolver
, const WebVector<WebPersistentNotificationInfo>& notificationInfos) |
| 39 { | 39 { |
| 40 HeapVector<Member<Notification>> notifications; | 40 HeapVector<Member<Notification>> notifications; |
| 41 for (const WebPersistentNotificationInfo& notificationInfo : *notificati
onInfos) | 41 for (const WebPersistentNotificationInfo& notificationInfo : notificatio
nInfos) |
| 42 notifications.append(Notification::create(resolver->executionContext
(), notificationInfo.persistentId, notificationInfo.data)); | 42 notifications.append(Notification::create(resolver->executionContext
(), notificationInfo.persistentId, notificationInfo.data)); |
| 43 return notifications; | 43 return notifications; |
| 44 } | 44 } |
| 45 | 45 |
| 46 private: | 46 private: |
| 47 NotificationArray() = delete; | 47 NotificationArray() = delete; |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 } // namespace | 50 } // namespace |
| 51 | 51 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 WebNotificationGetCallbacks* callbacks = new CallbackPromiseAdapter<Notifica
tionArray, void>(resolver); | 118 WebNotificationGetCallbacks* callbacks = new CallbackPromiseAdapter<Notifica
tionArray, void>(resolver); |
| 119 | 119 |
| 120 WebNotificationManager* notificationManager = Platform::current()->notificat
ionManager(); | 120 WebNotificationManager* notificationManager = Platform::current()->notificat
ionManager(); |
| 121 ASSERT(notificationManager); | 121 ASSERT(notificationManager); |
| 122 | 122 |
| 123 notificationManager->getNotifications(options.tag(), serviceWorkerRegistrati
on.webRegistration(), callbacks); | 123 notificationManager->getNotifications(options.tag(), serviceWorkerRegistrati
on.webRegistration(), callbacks); |
| 124 return promise; | 124 return promise; |
| 125 } | 125 } |
| 126 | 126 |
| 127 } // namespace blink | 127 } // namespace blink |
| OLD | NEW |