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 22 matching lines...) Expand all Loading... |
33 return *provider; | 33 return *provider; |
34 } | 34 } |
35 | 35 |
36 } // namespace | 36 } // namespace |
37 | 37 |
38 // static | 38 // static |
39 BroadcastChannel* BroadcastChannel::create(ExecutionContext* executionContext, | 39 BroadcastChannel* BroadcastChannel::create(ExecutionContext* executionContext, |
40 const String& name, | 40 const String& name, |
41 ExceptionState& exceptionState) { | 41 ExceptionState& exceptionState) { |
42 if (executionContext->getSecurityOrigin()->isUnique()) { | 42 if (executionContext->getSecurityOrigin()->isUnique()) { |
43 // TODO(mek): Decide what to do here depending on https://github.com/whatwg/
html/issues/1319 | 43 // TODO(mek): Decide what to do here depending on |
| 44 // https://github.com/whatwg/html/issues/1319 |
44 exceptionState.throwDOMException( | 45 exceptionState.throwDOMException( |
45 NotSupportedError, "Can't create BroadcastChannel in an opaque origin"); | 46 NotSupportedError, "Can't create BroadcastChannel in an opaque origin"); |
46 return nullptr; | 47 return nullptr; |
47 } | 48 } |
48 return new BroadcastChannel(executionContext, name); | 49 return new BroadcastChannel(executionContext, name); |
49 } | 50 } |
50 | 51 |
51 BroadcastChannel::~BroadcastChannel() {} | 52 BroadcastChannel::~BroadcastChannel() {} |
52 | 53 |
53 void BroadcastChannel::dispose() { | 54 void BroadcastChannel::dispose() { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 : ActiveScriptWrappable(this), | 118 : ActiveScriptWrappable(this), |
118 ContextLifecycleObserver(executionContext), | 119 ContextLifecycleObserver(executionContext), |
119 m_origin(executionContext->getSecurityOrigin()), | 120 m_origin(executionContext->getSecurityOrigin()), |
120 m_name(name), | 121 m_name(name), |
121 m_binding(this) { | 122 m_binding(this) { |
122 ThreadState::current()->registerPreFinalizer(this); | 123 ThreadState::current()->registerPreFinalizer(this); |
123 | 124 |
124 mojom::blink::BroadcastChannelProviderPtr& provider = | 125 mojom::blink::BroadcastChannelProviderPtr& provider = |
125 getThreadSpecificProvider(); | 126 getThreadSpecificProvider(); |
126 | 127 |
127 // Local BroadcastChannelClient for messages send from the browser to this cha
nnel. | 128 // Local BroadcastChannelClient for messages send from the browser to this |
| 129 // channel. |
128 mojom::blink::BroadcastChannelClientAssociatedPtrInfo localClientInfo; | 130 mojom::blink::BroadcastChannelClientAssociatedPtrInfo localClientInfo; |
129 m_binding.Bind(&localClientInfo, provider.associated_group()); | 131 m_binding.Bind(&localClientInfo, provider.associated_group()); |
130 m_binding.set_connection_error_handler(convertToBaseCallback( | 132 m_binding.set_connection_error_handler(convertToBaseCallback( |
131 WTF::bind(&BroadcastChannel::onError, wrapWeakPersistent(this)))); | 133 WTF::bind(&BroadcastChannel::onError, wrapWeakPersistent(this)))); |
132 | 134 |
133 // Remote BroadcastChannelClient for messages send from this channel to the br
owser. | 135 // Remote BroadcastChannelClient for messages send from this channel to the |
| 136 // browser. |
134 mojom::blink::BroadcastChannelClientAssociatedPtrInfo remoteClientInfo; | 137 mojom::blink::BroadcastChannelClientAssociatedPtrInfo remoteClientInfo; |
135 mojo::AssociatedInterfaceRequest<mojom::blink::BroadcastChannelClient> | 138 mojo::AssociatedInterfaceRequest<mojom::blink::BroadcastChannelClient> |
136 remoteCientRequest; | 139 remoteCientRequest; |
137 provider.associated_group()->CreateAssociatedInterface( | 140 provider.associated_group()->CreateAssociatedInterface( |
138 mojo::AssociatedGroup::WILL_PASS_REQUEST, &remoteClientInfo, | 141 mojo::AssociatedGroup::WILL_PASS_REQUEST, &remoteClientInfo, |
139 &remoteCientRequest); | 142 &remoteCientRequest); |
140 m_remoteClient.Bind(std::move(remoteClientInfo)); | 143 m_remoteClient.Bind(std::move(remoteClientInfo)); |
141 m_remoteClient.set_connection_error_handler(convertToBaseCallback( | 144 m_remoteClient.set_connection_error_handler(convertToBaseCallback( |
142 WTF::bind(&BroadcastChannel::onError, wrapWeakPersistent(this)))); | 145 WTF::bind(&BroadcastChannel::onError, wrapWeakPersistent(this)))); |
143 | 146 |
144 provider->ConnectToChannel(m_origin, m_name, std::move(localClientInfo), | 147 provider->ConnectToChannel(m_origin, m_name, std::move(localClientInfo), |
145 std::move(remoteCientRequest)); | 148 std::move(remoteCientRequest)); |
146 } | 149 } |
147 | 150 |
148 } // namespace blink | 151 } // namespace blink |
OLD | NEW |