| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 * | 24 * |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #ifndef MessagePort_h | 27 #ifndef MessagePort_h |
| 28 #define MessagePort_h | 28 #define MessagePort_h |
| 29 | 29 |
| 30 #include "bindings/core/v8/ActiveScriptWrappable.h" | 30 #include "bindings/core/v8/ActiveScriptWrappable.h" |
| 31 #include "bindings/core/v8/SerializedScriptValue.h" | 31 #include "bindings/core/v8/SerializedScriptValue.h" |
| 32 #include "core/CoreExport.h" | 32 #include "core/CoreExport.h" |
| 33 #include "core/dom/ActiveDOMObject.h" | 33 #include "core/dom/SuspendableObject.h" |
| 34 #include "core/events/EventListener.h" | 34 #include "core/events/EventListener.h" |
| 35 #include "core/events/EventTarget.h" | 35 #include "core/events/EventTarget.h" |
| 36 #include "public/platform/WebMessagePortChannel.h" | 36 #include "public/platform/WebMessagePortChannel.h" |
| 37 #include "public/platform/WebMessagePortChannelClient.h" | 37 #include "public/platform/WebMessagePortChannelClient.h" |
| 38 #include "wtf/PassRefPtr.h" | 38 #include "wtf/PassRefPtr.h" |
| 39 #include "wtf/RefPtr.h" | 39 #include "wtf/RefPtr.h" |
| 40 #include "wtf/Vector.h" | 40 #include "wtf/Vector.h" |
| 41 #include <memory> | 41 #include <memory> |
| 42 | 42 |
| 43 namespace blink { | 43 namespace blink { |
| 44 | 44 |
| 45 class ExceptionState; | 45 class ExceptionState; |
| 46 class ExecutionContext; | 46 class ExecutionContext; |
| 47 class MessagePort; | 47 class MessagePort; |
| 48 class SerializedScriptValue; | 48 class SerializedScriptValue; |
| 49 | 49 |
| 50 // Not to be confused with WebMessagePortChannelArray; this one uses Vector and | 50 // Not to be confused with WebMessagePortChannelArray; this one uses Vector and |
| 51 // std::unique_ptr instead of WebVector and raw pointers. | 51 // std::unique_ptr instead of WebVector and raw pointers. |
| 52 typedef Vector<WebMessagePortChannelUniquePtr, 1> MessagePortChannelArray; | 52 typedef Vector<WebMessagePortChannelUniquePtr, 1> MessagePortChannelArray; |
| 53 | 53 |
| 54 class CORE_EXPORT MessagePort : public EventTargetWithInlineData, | 54 class CORE_EXPORT MessagePort : public EventTargetWithInlineData, |
| 55 public ActiveScriptWrappable, | 55 public ActiveScriptWrappable, |
| 56 public ActiveDOMObject, | 56 public SuspendableObject, |
| 57 public WebMessagePortChannelClient { | 57 public WebMessagePortChannelClient { |
| 58 DEFINE_WRAPPERTYPEINFO(); | 58 DEFINE_WRAPPERTYPEINFO(); |
| 59 USING_GARBAGE_COLLECTED_MIXIN(MessagePort); | 59 USING_GARBAGE_COLLECTED_MIXIN(MessagePort); |
| 60 | 60 |
| 61 public: | 61 public: |
| 62 static MessagePort* create(ExecutionContext&); | 62 static MessagePort* create(ExecutionContext&); |
| 63 ~MessagePort() override; | 63 ~MessagePort() override; |
| 64 | 64 |
| 65 void postMessage(ExecutionContext*, | 65 void postMessage(ExecutionContext*, |
| 66 PassRefPtr<SerializedScriptValue> message, | 66 PassRefPtr<SerializedScriptValue> message, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 90 | 90 |
| 91 // Returns an empty array if the passed array is nullptr/empty. | 91 // Returns an empty array if the passed array is nullptr/empty. |
| 92 static MessagePortArray* entanglePorts( | 92 static MessagePortArray* entanglePorts( |
| 93 ExecutionContext&, | 93 ExecutionContext&, |
| 94 std::unique_ptr<MessagePortChannelArray>); | 94 std::unique_ptr<MessagePortChannelArray>); |
| 95 | 95 |
| 96 bool started() const { return m_started; } | 96 bool started() const { return m_started; } |
| 97 | 97 |
| 98 const AtomicString& interfaceName() const override; | 98 const AtomicString& interfaceName() const override; |
| 99 ExecutionContext* getExecutionContext() const override { | 99 ExecutionContext* getExecutionContext() const override { |
| 100 return ActiveDOMObject::getExecutionContext(); | 100 return SuspendableObject::getExecutionContext(); |
| 101 } | 101 } |
| 102 MessagePort* toMessagePort() override { return this; } | 102 MessagePort* toMessagePort() override { return this; } |
| 103 | 103 |
| 104 // ScriptWrappable implementation. | 104 // ScriptWrappable implementation. |
| 105 bool hasPendingActivity() const final; | 105 bool hasPendingActivity() const final; |
| 106 | 106 |
| 107 // ActiveDOMObject implementation. | 107 // SuspendableObject implementation. |
| 108 void contextDestroyed() override { close(); } | 108 void contextDestroyed() override { close(); } |
| 109 | 109 |
| 110 void setOnmessage(EventListener* listener) { | 110 void setOnmessage(EventListener* listener) { |
| 111 setAttributeEventListener(EventTypeNames::message, listener); | 111 setAttributeEventListener(EventTypeNames::message, listener); |
| 112 start(); | 112 start(); |
| 113 } | 113 } |
| 114 EventListener* onmessage() { | 114 EventListener* onmessage() { |
| 115 return getAttributeEventListener(EventTypeNames::message); | 115 return getAttributeEventListener(EventTypeNames::message); |
| 116 } | 116 } |
| 117 | 117 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 142 | 142 |
| 143 WebMessagePortChannelUniquePtr m_entangledChannel; | 143 WebMessagePortChannelUniquePtr m_entangledChannel; |
| 144 | 144 |
| 145 bool m_started; | 145 bool m_started; |
| 146 bool m_closed; | 146 bool m_closed; |
| 147 }; | 147 }; |
| 148 | 148 |
| 149 } // namespace blink | 149 } // namespace blink |
| 150 | 150 |
| 151 #endif // MessagePort_h | 151 #endif // MessagePort_h |
| OLD | NEW |