| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 // Not to be confused with WebMessagePortChannelArray; this one uses Vector and
OwnPtr instead of WebVector and raw pointers. | 56 // Not to be confused with WebMessagePortChannelArray; this one uses Vector and
OwnPtr instead of WebVector and raw pointers. |
| 57 typedef Vector<OwnPtr<WebMessagePortChannel>, 1> MessagePortChannelArray; | 57 typedef Vector<OwnPtr<WebMessagePortChannel>, 1> MessagePortChannelArray; |
| 58 | 58 |
| 59 class CORE_EXPORT MessagePort | 59 class CORE_EXPORT MessagePort |
| 60 : public RefCountedGarbageCollectedEventTargetWithInlineData<MessagePort> | 60 : public RefCountedGarbageCollectedEventTargetWithInlineData<MessagePort> |
| 61 , public ActiveScriptWrappable | 61 , public ActiveScriptWrappable |
| 62 , public ActiveDOMObject | 62 , public ActiveDOMObject |
| 63 , public WebMessagePortChannelClient { | 63 , public WebMessagePortChannelClient { |
| 64 DEFINE_WRAPPERTYPEINFO(); | 64 DEFINE_WRAPPERTYPEINFO(); |
| 65 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(MessagePort); | 65 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(MessagePort); |
| 66 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(MessagePort); | 66 USING_GARBAGE_COLLECTED_MIXIN(MessagePort); |
| 67 public: | 67 public: |
| 68 static MessagePort* create(ExecutionContext&); | 68 static MessagePort* create(ExecutionContext&); |
| 69 ~MessagePort() override; | 69 ~MessagePort() override; |
| 70 | 70 |
| 71 void postMessage(ExecutionContext*, PassRefPtr<SerializedScriptValue> messag
e, const MessagePortArray*, ExceptionState&); | 71 void postMessage(ExecutionContext*, PassRefPtr<SerializedScriptValue> messag
e, const MessagePortArray*, ExceptionState&); |
| 72 | 72 |
| 73 void start(); | 73 void start(); |
| 74 void close(); | 74 void close(); |
| 75 | 75 |
| 76 void entangle(PassOwnPtr<WebMessagePortChannel>); | 76 void entangle(PassOwnPtr<WebMessagePortChannel>); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 93 const AtomicString& interfaceName() const override; | 93 const AtomicString& interfaceName() const override; |
| 94 ExecutionContext* getExecutionContext() const override { return ActiveDOMObj
ect::getExecutionContext(); } | 94 ExecutionContext* getExecutionContext() const override { return ActiveDOMObj
ect::getExecutionContext(); } |
| 95 MessagePort* toMessagePort() override { return this; } | 95 MessagePort* toMessagePort() override { return this; } |
| 96 | 96 |
| 97 // ActiveScriptWrappable implementation. | 97 // ActiveScriptWrappable implementation. |
| 98 bool hasPendingActivity() const final; | 98 bool hasPendingActivity() const final; |
| 99 | 99 |
| 100 // ActiveDOMObject implementation. | 100 // ActiveDOMObject implementation. |
| 101 void stop() override { close(); } | 101 void stop() override { close(); } |
| 102 | 102 |
| 103 void setOnmessage(PassRefPtrWillBeRawPtr<EventListener> listener) | 103 void setOnmessage(RawPtr<EventListener> listener) |
| 104 { | 104 { |
| 105 setAttributeEventListener(EventTypeNames::message, listener); | 105 setAttributeEventListener(EventTypeNames::message, listener); |
| 106 start(); | 106 start(); |
| 107 } | 107 } |
| 108 EventListener* onmessage() { return getAttributeEventListener(EventTypeNames
::message); } | 108 EventListener* onmessage() { return getAttributeEventListener(EventTypeNames
::message); } |
| 109 | 109 |
| 110 // A port starts out its life entangled, and remains entangled until it is c
losed or is cloned. | 110 // A port starts out its life entangled, and remains entangled until it is c
losed or is cloned. |
| 111 bool isEntangled() const { return !m_closed && !isNeutered(); } | 111 bool isEntangled() const { return !m_closed && !isNeutered(); } |
| 112 | 112 |
| 113 // A port gets neutered when it is transferred to a new owner via postMessag
e(). | 113 // A port gets neutered when it is transferred to a new owner via postMessag
e(). |
| (...skipping 18 matching lines...) Expand all Loading... |
| 132 bool m_closed; | 132 bool m_closed; |
| 133 | 133 |
| 134 WeakPtrFactory<MessagePort> m_weakFactory; | 134 WeakPtrFactory<MessagePort> m_weakFactory; |
| 135 | 135 |
| 136 RefPtr<ScriptState> m_scriptStateForConversion; | 136 RefPtr<ScriptState> m_scriptStateForConversion; |
| 137 }; | 137 }; |
| 138 | 138 |
| 139 } // namespace blink | 139 } // namespace blink |
| 140 | 140 |
| 141 #endif // MessagePort_h | 141 #endif // MessagePort_h |
| OLD | NEW |