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