| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 close(); | 114 close(); |
| 115 } | 115 } |
| 116 | 116 |
| 117 BroadcastChannel::BroadcastChannel(ExecutionContext* executionContext, const Str
ing& name) | 117 BroadcastChannel::BroadcastChannel(ExecutionContext* executionContext, const Str
ing& name) |
| 118 : ActiveScriptWrappable(this) | 118 : ActiveScriptWrappable(this) |
| 119 , ContextLifecycleObserver(executionContext) | 119 , ContextLifecycleObserver(executionContext) |
| 120 , m_origin(executionContext->getSecurityOrigin()) | 120 , m_origin(executionContext->getSecurityOrigin()) |
| 121 , m_name(name) | 121 , m_name(name) |
| 122 , m_binding(this) | 122 , m_binding(this) |
| 123 { | 123 { |
| 124 ThreadState::current()->registerPreFinalizer(this); |
| 125 |
| 124 mojom::blink::BroadcastChannelProviderPtr& provider = getThreadSpecificProvi
der(); | 126 mojom::blink::BroadcastChannelProviderPtr& provider = getThreadSpecificProvi
der(); |
| 125 | 127 |
| 126 // Local BroadcastChannelClient for messages send from the browser to this c
hannel. | 128 // Local BroadcastChannelClient for messages send from the browser to this c
hannel. |
| 127 mojom::blink::BroadcastChannelClientAssociatedPtrInfo localClientInfo; | 129 mojom::blink::BroadcastChannelClientAssociatedPtrInfo localClientInfo; |
| 128 m_binding.Bind(&localClientInfo, provider.associated_group()); | 130 m_binding.Bind(&localClientInfo, provider.associated_group()); |
| 129 m_binding.set_connection_error_handler(convertToBaseCallback(WTF::bind(&Broa
dcastChannel::onError, wrapWeakPersistent(this)))); | 131 m_binding.set_connection_error_handler(convertToBaseCallback(WTF::bind(&Broa
dcastChannel::onError, wrapWeakPersistent(this)))); |
| 130 | 132 |
| 131 // Remote BroadcastChannelClient for messages send from this channel to the
browser. | 133 // Remote BroadcastChannelClient for messages send from this channel to the
browser. |
| 132 mojom::blink::BroadcastChannelClientAssociatedPtrInfo remoteClientInfo; | 134 mojom::blink::BroadcastChannelClientAssociatedPtrInfo remoteClientInfo; |
| 133 mojo::AssociatedInterfaceRequest<mojom::blink::BroadcastChannelClient> remot
eCientRequest; | 135 mojo::AssociatedInterfaceRequest<mojom::blink::BroadcastChannelClient> remot
eCientRequest; |
| 134 provider.associated_group()->CreateAssociatedInterface(mojo::AssociatedGroup
::WILL_PASS_REQUEST, &remoteClientInfo, &remoteCientRequest); | 136 provider.associated_group()->CreateAssociatedInterface(mojo::AssociatedGroup
::WILL_PASS_REQUEST, &remoteClientInfo, &remoteCientRequest); |
| 135 m_remoteClient.Bind(std::move(remoteClientInfo)); | 137 m_remoteClient.Bind(std::move(remoteClientInfo)); |
| 136 m_remoteClient.set_connection_error_handler(convertToBaseCallback(WTF::bind(
&BroadcastChannel::onError, wrapWeakPersistent(this)))); | 138 m_remoteClient.set_connection_error_handler(convertToBaseCallback(WTF::bind(
&BroadcastChannel::onError, wrapWeakPersistent(this)))); |
| 137 | 139 |
| 138 provider->ConnectToChannel(m_origin, m_name, std::move(localClientInfo), std
::move(remoteCientRequest)); | 140 provider->ConnectToChannel(m_origin, m_name, std::move(localClientInfo), std
::move(remoteCientRequest)); |
| 139 } | 141 } |
| 140 | 142 |
| 141 } // namespace blink | 143 } // namespace blink |
| OLD | NEW |