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 10 matching lines...) Expand all Loading... | |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
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 "core/CoreExport.h" | 32 #include "core/CoreExport.h" |
32 #include "core/dom/ActiveDOMObject.h" | 33 #include "core/dom/ActiveDOMObject.h" |
33 #include "core/events/EventListener.h" | 34 #include "core/events/EventListener.h" |
34 #include "core/events/EventTarget.h" | 35 #include "core/events/EventTarget.h" |
35 #include "public/platform/WebMessagePortChannel.h" | 36 #include "public/platform/WebMessagePortChannel.h" |
36 #include "public/platform/WebMessagePortChannelClient.h" | 37 #include "public/platform/WebMessagePortChannelClient.h" |
37 #include "wtf/OwnPtr.h" | 38 #include "wtf/OwnPtr.h" |
38 #include "wtf/PassOwnPtr.h" | 39 #include "wtf/PassOwnPtr.h" |
39 #include "wtf/PassRefPtr.h" | 40 #include "wtf/PassRefPtr.h" |
40 #include "wtf/RefPtr.h" | 41 #include "wtf/RefPtr.h" |
41 #include "wtf/Vector.h" | 42 #include "wtf/Vector.h" |
42 #include "wtf/WeakPtr.h" | 43 #include "wtf/WeakPtr.h" |
43 | 44 |
44 namespace blink { | 45 namespace blink { |
45 | 46 |
46 class ExceptionState; | 47 class ExceptionState; |
47 class ExecutionContext; | 48 class ExecutionContext; |
48 class MessagePort; | 49 class MessagePort; |
49 class ScriptState; | 50 class ScriptState; |
50 class SerializedScriptValue; | 51 class SerializedScriptValue; |
51 | 52 |
52 // The overwhelmingly common case is sending a single port, so handle that effic iently with an inline buffer of size 1. | |
sof
2016/04/18 06:41:56
note: I removed the use of an inline buffer as I d
| |
53 typedef HeapVector<Member<MessagePort>, 1> MessagePortArray; | |
54 | |
55 // Not to be confused with WebMessagePortChannelArray; this one uses Vector and OwnPtr instead of WebVector and raw pointers. | 53 // Not to be confused with WebMessagePortChannelArray; this one uses Vector and OwnPtr instead of WebVector and raw pointers. |
56 typedef Vector<OwnPtr<WebMessagePortChannel>, 1> MessagePortChannelArray; | 54 typedef Vector<OwnPtr<WebMessagePortChannel>, 1> MessagePortChannelArray; |
57 | 55 |
58 class CORE_EXPORT MessagePort | 56 class CORE_EXPORT MessagePort |
59 : public EventTargetWithInlineData | 57 : public EventTargetWithInlineData |
60 , public ActiveScriptWrappable | 58 , public ActiveScriptWrappable |
61 , public ActiveDOMObject | 59 , public ActiveDOMObject |
62 , public WebMessagePortChannelClient { | 60 , public WebMessagePortChannelClient { |
63 DEFINE_WRAPPERTYPEINFO(); | 61 DEFINE_WRAPPERTYPEINFO(); |
64 USING_GARBAGE_COLLECTED_MIXIN(MessagePort); | 62 USING_GARBAGE_COLLECTED_MIXIN(MessagePort); |
65 public: | 63 public: |
66 static MessagePort* create(ExecutionContext&); | 64 static MessagePort* create(ExecutionContext&); |
67 ~MessagePort() override; | 65 ~MessagePort() override; |
68 | 66 |
69 void postMessage(ExecutionContext*, PassRefPtr<SerializedScriptValue> messag e, const MessagePortArray*, ExceptionState&); | 67 void postMessage(ExecutionContext*, PassRefPtr<SerializedScriptValue> messag e, const MessagePortArray&, ExceptionState&); |
70 | 68 |
71 void start(); | 69 void start(); |
72 void close(); | 70 void close(); |
73 | 71 |
74 void entangle(PassOwnPtr<WebMessagePortChannel>); | 72 void entangle(PassOwnPtr<WebMessagePortChannel>); |
75 PassOwnPtr<WebMessagePortChannel> disentangle(); | 73 PassOwnPtr<WebMessagePortChannel> disentangle(); |
76 | 74 |
77 // Returns nullptr if the passed-in array is nullptr/empty. | 75 // Returns nullptr if the passed-in array is nullptr/empty. |
78 static PassOwnPtr<WebMessagePortChannelArray> toWebMessagePortChannelArray(P assOwnPtr<MessagePortChannelArray>); | 76 static PassOwnPtr<WebMessagePortChannelArray> toWebMessagePortChannelArray(P assOwnPtr<MessagePortChannelArray>); |
79 | 77 |
80 // Returns an empty array if the passed array is empty. | 78 // Returns an empty array if the passed array is empty. |
81 static MessagePortArray* toMessagePortArray(ExecutionContext*, const WebMess agePortChannelArray&); | 79 static MessagePortArray* toMessagePortArray(ExecutionContext*, const WebMess agePortChannelArray&); |
82 | 80 |
83 // Returns nullptr if there is an exception, or if the passed-in array is nu llptr/empty. | 81 // Returns nullptr if there is an exception, or if the passed-in array is nu llptr/empty. |
84 static PassOwnPtr<MessagePortChannelArray> disentanglePorts(ExecutionContext *, const MessagePortArray*, ExceptionState&); | 82 static PassOwnPtr<MessagePortChannelArray> disentanglePorts(ExecutionContext *, const MessagePortArray&, ExceptionState&); |
85 | 83 |
86 // Returns an empty array if the passed array is nullptr/empty. | 84 // Returns an empty array if the passed array is nullptr/empty. |
87 static MessagePortArray* entanglePorts(ExecutionContext&, PassOwnPtr<Message PortChannelArray>); | 85 static MessagePortArray* entanglePorts(ExecutionContext&, PassOwnPtr<Message PortChannelArray>); |
88 | 86 |
89 bool started() const { return m_started; } | 87 bool started() const { return m_started; } |
90 | 88 |
91 const AtomicString& interfaceName() const override; | 89 const AtomicString& interfaceName() const override; |
92 ExecutionContext* getExecutionContext() const override { return ActiveDOMObj ect::getExecutionContext(); } | 90 ExecutionContext* getExecutionContext() const override { return ActiveDOMObj ect::getExecutionContext(); } |
93 MessagePort* toMessagePort() override { return this; } | 91 MessagePort* toMessagePort() override { return this; } |
94 | 92 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
130 bool m_closed; | 128 bool m_closed; |
131 | 129 |
132 WeakPtrFactory<MessagePort> m_weakFactory; | 130 WeakPtrFactory<MessagePort> m_weakFactory; |
133 | 131 |
134 RefPtr<ScriptState> m_scriptStateForConversion; | 132 RefPtr<ScriptState> m_scriptStateForConversion; |
135 }; | 133 }; |
136 | 134 |
137 } // namespace blink | 135 } // namespace blink |
138 | 136 |
139 #endif // MessagePort_h | 137 #endif // MessagePort_h |
OLD | NEW |