| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/navigatorconnect/ServicePortCollection.h" | 5 #include "modules/navigatorconnect/ServicePortCollection.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptPromiseResolver.h" | 7 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 8 #include "bindings/core/v8/SerializedScriptValueFactory.h" | 8 #include "bindings/core/v8/SerializedScriptValueFactory.h" |
| 9 #include "core/dom/DOMException.h" | 9 #include "core/dom/DOMException.h" |
| 10 #include "core/dom/ExceptionCode.h" | 10 #include "core/dom/ExceptionCode.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 { | 135 { |
| 136 OwnPtr<MessagePortChannelArray> channels; | 136 OwnPtr<MessagePortChannelArray> channels; |
| 137 if (webChannels.size()) { | 137 if (webChannels.size()) { |
| 138 channels = adoptPtr(new MessagePortChannelArray(webChannels.size())); | 138 channels = adoptPtr(new MessagePortChannelArray(webChannels.size())); |
| 139 for (size_t i = 0; i < webChannels.size(); ++i) | 139 for (size_t i = 0; i < webChannels.size(); ++i) |
| 140 (*channels)[i] = adoptPtr(webChannels[i]); | 140 (*channels)[i] = adoptPtr(webChannels[i]); |
| 141 } | 141 } |
| 142 RefPtr<SerializedScriptValue> message = SerializedScriptValueFactory::instan
ce().createFromWire(messageString); | 142 RefPtr<SerializedScriptValue> message = SerializedScriptValueFactory::instan
ce().createFromWire(messageString); |
| 143 | 143 |
| 144 MessagePortArray* ports = MessagePort::entanglePorts(*getExecutionContext(),
channels.release()); | 144 MessagePortArray* ports = MessagePort::entanglePorts(*getExecutionContext(),
channels.release()); |
| 145 RefPtrWillBeRawPtr<Event> evt = MessageEvent::create(ports, message.release(
)); | 145 RawPtr<Event> evt = MessageEvent::create(ports, message.release()); |
| 146 // TODO(mek): Lookup ServicePort and set events source attribute. | 146 // TODO(mek): Lookup ServicePort and set events source attribute. |
| 147 dispatchEvent(evt.release()); | 147 dispatchEvent(evt.release()); |
| 148 } | 148 } |
| 149 | 149 |
| 150 void ServicePortCollection::dispatchConnectEvent(PassOwnPtr<WebServicePortConnec
tEventCallbacks> callbacks, const WebURL& targetURL, const WebString& origin, We
bServicePortID portID) | 150 void ServicePortCollection::dispatchConnectEvent(PassOwnPtr<WebServicePortConnec
tEventCallbacks> callbacks, const WebURL& targetURL, const WebString& origin, We
bServicePortID portID) |
| 151 { | 151 { |
| 152 AcceptConnectionObserver* observer = AcceptConnectionObserver::create(this,
callbacks, portID, targetURL); | 152 AcceptConnectionObserver* observer = AcceptConnectionObserver::create(this,
callbacks, portID, targetURL); |
| 153 ServicePortConnectEventInit init; | 153 ServicePortConnectEventInit init; |
| 154 init.setTargetURL(targetURL.string()); | 154 init.setTargetURL(targetURL.string()); |
| 155 init.setOrigin(origin); | 155 init.setOrigin(origin); |
| 156 RefPtrWillBeRawPtr<Event> event = ServicePortConnectEvent::create(EventTypeN
ames::connect, init, observer); | 156 RawPtr<Event> event = ServicePortConnectEvent::create(EventTypeNames::connec
t, init, observer); |
| 157 dispatchEvent(event.release()); | 157 dispatchEvent(event.release()); |
| 158 observer->didDispatchEvent(); | 158 observer->didDispatchEvent(); |
| 159 } | 159 } |
| 160 | 160 |
| 161 DEFINE_TRACE(ServicePortCollection) | 161 DEFINE_TRACE(ServicePortCollection) |
| 162 { | 162 { |
| 163 visitor->trace(m_ports); | 163 visitor->trace(m_ports); |
| 164 RefCountedGarbageCollectedEventTargetWithInlineData<ServicePortCollection>::
trace(visitor); | 164 RefCountedGarbageCollectedEventTargetWithInlineData<ServicePortCollection>::
trace(visitor); |
| 165 ContextLifecycleObserver::trace(visitor); | 165 ContextLifecycleObserver::trace(visitor); |
| 166 } | 166 } |
| 167 | 167 |
| 168 ServicePortCollection::ServicePortCollection(ExecutionContext* context) | 168 ServicePortCollection::ServicePortCollection(ExecutionContext* context) |
| 169 : ContextLifecycleObserver(context) | 169 : ContextLifecycleObserver(context) |
| 170 , m_provider(adoptPtr(Platform::current()->createServicePortProvider(this))) | 170 , m_provider(adoptPtr(Platform::current()->createServicePortProvider(this))) |
| 171 { | 171 { |
| 172 } | 172 } |
| 173 | 173 |
| 174 } // namespace blink | 174 } // namespace blink |
| OLD | NEW |