OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/broadcastchannel/BroadcastChannel.h" | 5 #include "modules/broadcastchannel/BroadcastChannel.h" |
6 | 6 |
7 #include "bindings/core/v8/SerializedScriptValue.h" | 7 #include "bindings/core/v8/SerializedScriptValue.h" |
8 #include "core/dom/ExceptionCode.h" | 8 #include "core/dom/ExceptionCode.h" |
9 #include "core/events/EventQueue.h" | 9 #include "core/events/EventQueue.h" |
10 #include "core/events/MessageEvent.h" | 10 #include "core/events/MessageEvent.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 101 |
102 DEFINE_TRACE(BroadcastChannel) { | 102 DEFINE_TRACE(BroadcastChannel) { |
103 ContextLifecycleObserver::trace(visitor); | 103 ContextLifecycleObserver::trace(visitor); |
104 EventTargetWithInlineData::trace(visitor); | 104 EventTargetWithInlineData::trace(visitor); |
105 } | 105 } |
106 | 106 |
107 void BroadcastChannel::OnMessage(const WTF::Vector<uint8_t>& message) { | 107 void BroadcastChannel::OnMessage(const WTF::Vector<uint8_t>& message) { |
108 // Queue a task to dispatch the event. | 108 // Queue a task to dispatch the event. |
109 RefPtr<SerializedScriptValue> value = SerializedScriptValue::create( | 109 RefPtr<SerializedScriptValue> value = SerializedScriptValue::create( |
110 message.isEmpty() ? nullptr | 110 message.isEmpty() ? nullptr |
111 : reinterpret_cast<const char*>(&message.first()), | 111 : reinterpret_cast<const char*>(&message.front()), |
112 message.size()); | 112 message.size()); |
113 MessageEvent* event = MessageEvent::create( | 113 MessageEvent* event = MessageEvent::create( |
114 nullptr, value.release(), | 114 nullptr, value.release(), |
115 getExecutionContext()->getSecurityOrigin()->toString()); | 115 getExecutionContext()->getSecurityOrigin()->toString()); |
116 event->setTarget(this); | 116 event->setTarget(this); |
117 bool success = getExecutionContext()->getEventQueue()->enqueueEvent(event); | 117 bool success = getExecutionContext()->getEventQueue()->enqueueEvent(event); |
118 DCHECK(success); | 118 DCHECK(success); |
119 ALLOW_UNUSED_LOCAL(success); | 119 ALLOW_UNUSED_LOCAL(success); |
120 } | 120 } |
121 | 121 |
(...skipping 30 matching lines...) Expand all Loading... |
152 &remoteCientRequest); | 152 &remoteCientRequest); |
153 m_remoteClient.Bind(std::move(remoteClientInfo)); | 153 m_remoteClient.Bind(std::move(remoteClientInfo)); |
154 m_remoteClient.set_connection_error_handler(convertToBaseCallback( | 154 m_remoteClient.set_connection_error_handler(convertToBaseCallback( |
155 WTF::bind(&BroadcastChannel::onError, wrapWeakPersistent(this)))); | 155 WTF::bind(&BroadcastChannel::onError, wrapWeakPersistent(this)))); |
156 | 156 |
157 provider->ConnectToChannel(m_origin, m_name, std::move(localClientInfo), | 157 provider->ConnectToChannel(m_origin, m_name, std::move(localClientInfo), |
158 std::move(remoteCientRequest)); | 158 std::move(remoteCientRequest)); |
159 } | 159 } |
160 | 160 |
161 } // namespace blink | 161 } // namespace blink |
OLD | NEW |