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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 close(); | 55 close(); |
56 } | 56 } |
57 | 57 |
58 void BroadcastChannel::postMessage(const ScriptValue& message, | 58 void BroadcastChannel::postMessage(const ScriptValue& message, |
59 ExceptionState& exceptionState) { | 59 ExceptionState& exceptionState) { |
60 if (!m_binding.is_bound()) { | 60 if (!m_binding.is_bound()) { |
61 exceptionState.throwDOMException(InvalidStateError, "Channel is closed"); | 61 exceptionState.throwDOMException(InvalidStateError, "Channel is closed"); |
62 return; | 62 return; |
63 } | 63 } |
64 RefPtr<SerializedScriptValue> value = SerializedScriptValue::serialize( | 64 RefPtr<SerializedScriptValue> value = SerializedScriptValue::serialize( |
65 message.isolate(), message.v8Value(), nullptr, nullptr, exceptionState); | 65 message.isolate(), message.v8Value(), |
| 66 SerializedScriptValue::SerializeOptions(), exceptionState); |
66 if (exceptionState.hadException()) | 67 if (exceptionState.hadException()) |
67 return; | 68 return; |
68 | 69 |
69 Vector<char> data; | 70 Vector<char> data; |
70 value->toWireBytes(data); | 71 value->toWireBytes(data); |
71 Vector<uint8_t> mojoData; | 72 Vector<uint8_t> mojoData; |
72 mojoData.appendVector(data); | 73 mojoData.appendVector(data); |
73 m_remoteClient->OnMessage(std::move(mojoData)); | 74 m_remoteClient->OnMessage(std::move(mojoData)); |
74 } | 75 } |
75 | 76 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 // browser. | 136 // browser. |
136 auto remoteCientRequest = mojo::MakeRequest(&m_remoteClient); | 137 auto remoteCientRequest = mojo::MakeRequest(&m_remoteClient); |
137 m_remoteClient.set_connection_error_handler(convertToBaseCallback( | 138 m_remoteClient.set_connection_error_handler(convertToBaseCallback( |
138 WTF::bind(&BroadcastChannel::onError, wrapWeakPersistent(this)))); | 139 WTF::bind(&BroadcastChannel::onError, wrapWeakPersistent(this)))); |
139 | 140 |
140 provider->ConnectToChannel(m_origin, m_name, std::move(localClientInfo), | 141 provider->ConnectToChannel(m_origin, m_name, std::move(localClientInfo), |
141 std::move(remoteCientRequest)); | 142 std::move(remoteCientRequest)); |
142 } | 143 } |
143 | 144 |
144 } // namespace blink | 145 } // namespace blink |
OLD | NEW |