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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 const MessagePortArray&, | 67 const MessagePortArray&, |
68 ExceptionState&); | 68 ExceptionState&); |
69 static bool canTransferArrayBuffersAndImageBitmaps() { return false; } | 69 static bool canTransferArrayBuffersAndImageBitmaps() { return false; } |
70 | 70 |
71 void start(); | 71 void start(); |
72 void close(); | 72 void close(); |
73 | 73 |
74 void entangle(WebMessagePortChannelUniquePtr); | 74 void entangle(WebMessagePortChannelUniquePtr); |
75 WebMessagePortChannelUniquePtr disentangle(); | 75 WebMessagePortChannelUniquePtr disentangle(); |
76 | 76 |
77 // Returns nullptr if the passed-in array is nullptr/empty. | 77 static WebMessagePortChannelArray toWebMessagePortChannelArray( |
78 static std::unique_ptr<WebMessagePortChannelArray> | 78 MessagePortChannelArray); |
79 toWebMessagePortChannelArray(std::unique_ptr<MessagePortChannelArray>); | |
80 | 79 |
81 // Returns an empty array if the passed array is empty. | 80 // Returns an empty array if the passed array is empty. |
82 static MessagePortArray* toMessagePortArray( | 81 static MessagePortArray* toMessagePortArray(ExecutionContext*, |
83 ExecutionContext*, | 82 WebMessagePortChannelArray); |
84 const WebMessagePortChannelArray&); | |
85 | 83 |
86 // Returns nullptr if there is an exception, or if the passed-in array is | 84 // Returns an empty array if there is an exception, or if the passed array is |
87 // nullptr/empty. | 85 // nullptr/empty. |
88 static std::unique_ptr<MessagePortChannelArray> | 86 static MessagePortChannelArray disentanglePorts(ExecutionContext*, |
89 disentanglePorts(ExecutionContext*, const MessagePortArray&, ExceptionState&); | 87 const MessagePortArray&, |
| 88 ExceptionState&); |
90 | 89 |
91 // Returns an empty array if the passed array is nullptr/empty. | 90 // Returns an empty array if the passed array is empty. |
92 static MessagePortArray* entanglePorts( | 91 static MessagePortArray* entanglePorts(ExecutionContext&, |
93 ExecutionContext&, | 92 MessagePortChannelArray); |
94 std::unique_ptr<MessagePortChannelArray>); | |
95 | 93 |
96 bool started() const { return m_started; } | 94 bool started() const { return m_started; } |
97 | 95 |
98 const AtomicString& interfaceName() const override; | 96 const AtomicString& interfaceName() const override; |
99 ExecutionContext* getExecutionContext() const override { | 97 ExecutionContext* getExecutionContext() const override { |
100 return ContextLifecycleObserver::getExecutionContext(); | 98 return ContextLifecycleObserver::getExecutionContext(); |
101 } | 99 } |
102 MessagePort* toMessagePort() override { return this; } | 100 MessagePort* toMessagePort() override { return this; } |
103 | 101 |
104 // ScriptWrappable implementation. | 102 // ScriptWrappable implementation. |
(...skipping 21 matching lines...) Expand all Loading... |
126 // For testing only: allows inspection of the entangled channel. | 124 // For testing only: allows inspection of the entangled channel. |
127 WebMessagePortChannel* entangledChannelForTesting() const { | 125 WebMessagePortChannel* entangledChannelForTesting() const { |
128 return m_entangledChannel.get(); | 126 return m_entangledChannel.get(); |
129 } | 127 } |
130 | 128 |
131 DECLARE_VIRTUAL_TRACE(); | 129 DECLARE_VIRTUAL_TRACE(); |
132 | 130 |
133 protected: | 131 protected: |
134 explicit MessagePort(ExecutionContext&); | 132 explicit MessagePort(ExecutionContext&); |
135 bool tryGetMessage(RefPtr<SerializedScriptValue>& message, | 133 bool tryGetMessage(RefPtr<SerializedScriptValue>& message, |
136 std::unique_ptr<MessagePortChannelArray>& channels); | 134 MessagePortChannelArray& channels); |
137 | 135 |
138 private: | 136 private: |
139 // WebMessagePortChannelClient implementation. | 137 // WebMessagePortChannelClient implementation. |
140 void messageAvailable() override; | 138 void messageAvailable() override; |
141 void dispatchMessages(); | 139 void dispatchMessages(); |
142 | 140 |
143 WebMessagePortChannelUniquePtr m_entangledChannel; | 141 WebMessagePortChannelUniquePtr m_entangledChannel; |
144 | 142 |
145 bool m_started; | 143 bool m_started; |
146 bool m_closed; | 144 bool m_closed; |
147 }; | 145 }; |
148 | 146 |
149 } // namespace blink | 147 } // namespace blink |
150 | 148 |
151 #endif // MessagePort_h | 149 #endif // MessagePort_h |
OLD | NEW |