OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef ServiceWorkerMessageEvent_h |
| 6 #define ServiceWorkerMessageEvent_h |
| 7 |
| 8 #include "bindings/modules/v8/UnionTypesModules.h" |
| 9 #include "core/dom/DOMArrayBuffer.h" |
| 10 #include "core/dom/MessagePort.h" |
| 11 #include "modules/EventModules.h" |
| 12 #include "modules/ModulesExport.h" |
| 13 #include "modules/serviceworkers/ServiceWorker.h" |
| 14 |
| 15 namespace blink { |
| 16 |
| 17 struct ServiceWorkerMessageEventInit : public EventInit { |
| 18 ServiceWorkerMessageEventInit(); |
| 19 |
| 20 String origin; |
| 21 String lastEventId; |
| 22 ServiceWorkerOrMessagePort source; |
| 23 MessagePortArray ports; |
| 24 }; |
| 25 |
| 26 class MODULES_EXPORT ServiceWorkerMessageEvent final : public Event { |
| 27 DEFINE_WRAPPERTYPEINFO(); |
| 28 public: |
| 29 static PassRefPtrWillBeRawPtr<ServiceWorkerMessageEvent> create() |
| 30 { |
| 31 return adoptRefWillBeNoop(new ServiceWorkerMessageEvent); |
| 32 } |
| 33 |
| 34 static PassRefPtrWillBeRawPtr<ServiceWorkerMessageEvent> create(const Atomic
String& type, ServiceWorkerMessageEventInit& initializer) |
| 35 { |
| 36 return adoptRefWillBeNoop(new ServiceWorkerMessageEvent(type, initialize
r)); |
| 37 } |
| 38 |
| 39 virtual ~ServiceWorkerMessageEvent(); |
| 40 |
| 41 void initServiceWorkerMessageEvent(const AtomicString& type, bool canBubble,
bool cancelable, const String& origin, const String& lastEventId, const Service
WorkerOrMessagePort& source, PassOwnPtrWillBeRawPtr<MessagePortArray> ports); |
| 42 |
| 43 const String& origin() const { return m_origin; } |
| 44 const String& lastEventId() const { return m_lastEventId; } |
| 45 void source(ServiceWorkerOrMessagePort& result) const { result = m_source; } |
| 46 MessagePortArray ports() const { return m_ports ? *m_ports : MessagePortArra
y(); } |
| 47 |
| 48 virtual const AtomicString& interfaceName() const override; |
| 49 |
| 50 SerializedScriptValue* serializedData() const { return m_serializedData.get(
); } |
| 51 |
| 52 void setSerializedData(PassRefPtr<SerializedScriptValue> data) |
| 53 { |
| 54 ASSERT(!m_serializedData); |
| 55 m_serializedData = data; |
| 56 } |
| 57 |
| 58 DECLARE_VIRTUAL_TRACE(); |
| 59 |
| 60 private: |
| 61 ServiceWorkerMessageEvent(); |
| 62 ServiceWorkerMessageEvent(const AtomicString& type, const ServiceWorkerMessa
geEventInit& initializer); |
| 63 |
| 64 String m_origin; |
| 65 String m_lastEventId; |
| 66 ServiceWorkerOrMessagePort m_source; |
| 67 RefPtr<SerializedScriptValue> m_serializedData; |
| 68 OwnPtrWillBeMember<MessagePortArray> m_ports; |
| 69 }; |
| 70 |
| 71 } // namespace blink |
| 72 |
| 73 #endif // ServiceWorkerMessageEvent_h |
OLD | NEW |