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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 return; | 67 return; |
68 | 68 |
69 Vector<char> data; | 69 Vector<char> data; |
70 value->toWireBytes(data); | 70 value->toWireBytes(data); |
71 Vector<uint8_t> mojoData; | 71 Vector<uint8_t> mojoData; |
72 mojoData.appendVector(data); | 72 mojoData.appendVector(data); |
73 m_remoteClient->OnMessage(std::move(mojoData)); | 73 m_remoteClient->OnMessage(std::move(mojoData)); |
74 } | 74 } |
75 | 75 |
76 void BroadcastChannel::close() { | 76 void BroadcastChannel::close() { |
| 77 if (!Platform::current()) { |
| 78 // TODO(rockot): Remove this hack once renderer shutdown sequence is fixed. |
| 79 // Note that reaching this code indicates that the MessageLoop has already |
| 80 // been torn down, so it's impossible for further incoming messages to be |
| 81 // dispatched on |m_binding| or reply callbacks to be invoked from |
| 82 // |m_remoteClient|. |
| 83 return; |
| 84 } |
77 m_remoteClient.reset(); | 85 m_remoteClient.reset(); |
78 if (m_binding.is_bound()) | 86 if (m_binding.is_bound()) |
79 m_binding.Close(); | 87 m_binding.Close(); |
80 } | 88 } |
81 | 89 |
82 const AtomicString& BroadcastChannel::interfaceName() const { | 90 const AtomicString& BroadcastChannel::interfaceName() const { |
83 return EventTargetNames::BroadcastChannel; | 91 return EventTargetNames::BroadcastChannel; |
84 } | 92 } |
85 | 93 |
86 bool BroadcastChannel::hasPendingActivity() const { | 94 bool BroadcastChannel::hasPendingActivity() const { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 &remoteCientRequest); | 150 &remoteCientRequest); |
143 m_remoteClient.Bind(std::move(remoteClientInfo)); | 151 m_remoteClient.Bind(std::move(remoteClientInfo)); |
144 m_remoteClient.set_connection_error_handler(convertToBaseCallback( | 152 m_remoteClient.set_connection_error_handler(convertToBaseCallback( |
145 WTF::bind(&BroadcastChannel::onError, wrapWeakPersistent(this)))); | 153 WTF::bind(&BroadcastChannel::onError, wrapWeakPersistent(this)))); |
146 | 154 |
147 provider->ConnectToChannel(m_origin, m_name, std::move(localClientInfo), | 155 provider->ConnectToChannel(m_origin, m_name, std::move(localClientInfo), |
148 std::move(remoteCientRequest)); | 156 std::move(remoteCientRequest)); |
149 } | 157 } |
150 | 158 |
151 } // namespace blink | 159 } // namespace blink |
OLD | NEW |