| 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 #ifndef ServiceWorkerRegistrationNotifications_h | 5 #ifndef ServiceWorkerRegistrationNotifications_h |
| 6 #define ServiceWorkerRegistrationNotifications_h | 6 #define ServiceWorkerRegistrationNotifications_h |
| 7 | 7 |
| 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
| 8 #include "bindings/core/v8/ScriptPromise.h" | 9 #include "bindings/core/v8/ScriptPromise.h" |
| 9 #include "core/dom/ContextLifecycleObserver.h" | 10 #include "core/dom/ContextLifecycleObserver.h" |
| 10 #include "platform/Supplementable.h" | 11 #include "platform/Supplementable.h" |
| 11 #include "platform/heap/GarbageCollected.h" | 12 #include "platform/heap/GarbageCollected.h" |
| 12 #include "platform/heap/Handle.h" | 13 #include "platform/heap/Handle.h" |
| 13 #include "platform/heap/HeapAllocator.h" | 14 #include "platform/heap/HeapAllocator.h" |
| 14 #include "platform/heap/Visitor.h" | 15 #include "platform/heap/Visitor.h" |
| 15 #include "public/platform/modules/notifications/WebNotificationManager.h" | 16 #include "public/platform/modules/notifications/notification.mojom-wtf.h" |
| 17 #include "public/platform/modules/notifications/notification_service.mojom-wtf.h
" |
| 16 #include "wtf/Noncopyable.h" | 18 #include "wtf/Noncopyable.h" |
| 17 #include "wtf/OwnPtr.h" | 19 #include "wtf/OwnPtr.h" |
| 18 #include "wtf/PassOwnPtr.h" | 20 #include "wtf/PassOwnPtr.h" |
| 19 #include "wtf/PassRefPtr.h" | 21 #include "wtf/PassRefPtr.h" |
| 20 | 22 |
| 21 namespace blink { | 23 namespace blink { |
| 22 | 24 |
| 23 class ExecutionContext; | 25 class ExecutionContext; |
| 24 class ExceptionState; | 26 class ExceptionState; |
| 25 class GetNotificationOptions; | 27 class GetNotificationOptions; |
| 26 class NotificationOptions; | 28 class NotificationOptions; |
| 27 class NotificationResourcesLoader; | 29 class NotificationResourcesLoader; |
| 28 class ScriptState; | 30 class ScriptState; |
| 29 class SecurityOrigin; | 31 class SecurityOrigin; |
| 30 class ServiceWorkerRegistration; | 32 class ServiceWorkerRegistration; |
| 31 struct WebNotificationData; | 33 struct WebNotificationData; |
| 32 | 34 |
| 33 class ServiceWorkerRegistrationNotifications final : public GarbageCollectedFina
lized<ServiceWorkerRegistrationNotifications>, public Supplement<ServiceWorkerRe
gistration>, public ContextLifecycleObserver { | 35 class ServiceWorkerRegistrationNotifications final : public GarbageCollectedFina
lized<ServiceWorkerRegistrationNotifications>, public Supplement<ServiceWorkerRe
gistration>, public ContextLifecycleObserver { |
| 34 USING_GARBAGE_COLLECTED_MIXIN(ServiceWorkerRegistrationNotifications); | 36 USING_GARBAGE_COLLECTED_MIXIN(ServiceWorkerRegistrationNotifications); |
| 35 WTF_MAKE_NONCOPYABLE(ServiceWorkerRegistrationNotifications); | 37 WTF_MAKE_NONCOPYABLE(ServiceWorkerRegistrationNotifications); |
| 38 |
| 39 using ShowNotificationCallbacks = CallbackPromiseAdapter<void, void>; |
| 40 |
| 36 public: | 41 public: |
| 37 ~ServiceWorkerRegistrationNotifications(); | 42 ~ServiceWorkerRegistrationNotifications(); |
| 38 static ScriptPromise showNotification(ScriptState*, ServiceWorkerRegistratio
n&, const String& title, const NotificationOptions&, ExceptionState&); | 43 static ScriptPromise showNotification(ScriptState*, ServiceWorkerRegistratio
n&, const String& title, const NotificationOptions&, ExceptionState&); |
| 39 static ScriptPromise getNotifications(ScriptState*, ServiceWorkerRegistratio
n&, const GetNotificationOptions&); | 44 static ScriptPromise getNotifications(ScriptState*, ServiceWorkerRegistratio
n&, const GetNotificationOptions&); |
| 40 | 45 |
| 41 // ContextLifecycleObserver interface. | 46 // ContextLifecycleObserver interface. |
| 42 void contextDestroyed() override; | 47 void contextDestroyed() override; |
| 43 | 48 |
| 44 DECLARE_VIRTUAL_TRACE(); | 49 DECLARE_VIRTUAL_TRACE(); |
| 45 | 50 |
| 46 private: | 51 private: |
| 47 ServiceWorkerRegistrationNotifications(ExecutionContext*, ServiceWorkerRegis
tration*); | 52 ServiceWorkerRegistrationNotifications(ExecutionContext*, ServiceWorkerRegis
tration*); |
| 48 | 53 |
| 49 static const char* supplementName(); | 54 static const char* supplementName(); |
| 50 static ServiceWorkerRegistrationNotifications& from(ExecutionContext*, Servi
ceWorkerRegistration&); | 55 static ServiceWorkerRegistrationNotifications& from(ExecutionContext*, Servi
ceWorkerRegistration&); |
| 51 | 56 |
| 52 void prepareShow(const WebNotificationData&, PassOwnPtr<WebNotificationShowC
allbacks>); | 57 void prepareShow(mojom::wtf::NotificationPtr, const mojom::wtf::Notification
Service::ShowPersistentCallback& callback); |
| 53 void didLoadResources(PassRefPtr<SecurityOrigin>, const WebNotificationData&
, PassOwnPtr<WebNotificationShowCallbacks>, NotificationResourcesLoader*); | 58 void didLoadResources(const mojom::wtf::NotificationService::ShowPersistentC
allback& callback, NotificationResourcesLoader*, mojom::wtf::NotificationPtr not
ification); |
| 54 | 59 |
| 55 Member<ServiceWorkerRegistration> m_registration; | 60 Member<ServiceWorkerRegistration> m_registration; |
| 56 HeapHashSet<Member<NotificationResourcesLoader>> m_loaders; | 61 HeapHashSet<Member<NotificationResourcesLoader>> m_loaders; |
| 57 }; | 62 }; |
| 58 | 63 |
| 59 } // namespace blink | 64 } // namespace blink |
| 60 | 65 |
| 61 #endif // ServiceWorkerRegistrationNotifications_h | 66 #endif // ServiceWorkerRegistrationNotifications_h |
| OLD | NEW |