| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 void ContextDestroyed(ExecutionContext*) override { close(); } | 107 void ContextDestroyed(ExecutionContext*) override { close(); } |
| 108 | 108 |
| 109 void setOnmessage(EventListener* listener) { | 109 void setOnmessage(EventListener* listener) { |
| 110 SetAttributeEventListener(EventTypeNames::message, listener); | 110 SetAttributeEventListener(EventTypeNames::message, listener); |
| 111 start(); | 111 start(); |
| 112 } | 112 } |
| 113 EventListener* onmessage() { | 113 EventListener* onmessage() { |
| 114 return GetAttributeEventListener(EventTypeNames::message); | 114 return GetAttributeEventListener(EventTypeNames::message); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void setOnmessageerror(EventListener* listener) { |
| 118 SetAttributeEventListener(EventTypeNames::messageerror, listener); |
| 119 start(); |
| 120 } |
| 121 EventListener* onmessageerror() { |
| 122 return GetAttributeEventListener(EventTypeNames::messageerror); |
| 123 } |
| 124 |
| 117 // A port starts out its life entangled, and remains entangled until it is | 125 // A port starts out its life entangled, and remains entangled until it is |
| 118 // closed or is cloned. | 126 // closed or is cloned. |
| 119 bool IsEntangled() const { return !closed_ && !IsNeutered(); } | 127 bool IsEntangled() const { return !closed_ && !IsNeutered(); } |
| 120 | 128 |
| 121 // A port gets neutered when it is transferred to a new owner via | 129 // A port gets neutered when it is transferred to a new owner via |
| 122 // postMessage(). | 130 // postMessage(). |
| 123 bool IsNeutered() const { return !entangled_channel_; } | 131 bool IsNeutered() const { return !entangled_channel_; } |
| 124 | 132 |
| 125 // For testing only: allows inspection of the entangled channel. | 133 // For testing only: allows inspection of the entangled channel. |
| 126 WebMessagePortChannel* EntangledChannelForTesting() const { | 134 WebMessagePortChannel* EntangledChannelForTesting() const { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 144 int pending_dispatch_task_ = 0; | 152 int pending_dispatch_task_ = 0; |
| 145 bool started_ = false; | 153 bool started_ = false; |
| 146 bool closed_ = false; | 154 bool closed_ = false; |
| 147 | 155 |
| 148 RefPtr<WebTaskRunner> task_runner_; | 156 RefPtr<WebTaskRunner> task_runner_; |
| 149 }; | 157 }; |
| 150 | 158 |
| 151 } // namespace blink | 159 } // namespace blink |
| 152 | 160 |
| 153 #endif // MessagePort_h | 161 #endif // MessagePort_h |
| OLD | NEW |