OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef BroadcastChannel_h |
| 6 #define BroadcastChannel_h |
| 7 |
| 8 #include "bindings/core/v8/ActiveScriptWrappable.h" |
| 9 #include "components/webmessaging/public/interfaces/broadcast_channel.mojom-blin
k.h" |
| 10 #include "core/dom/ContextLifecycleObserver.h" |
| 11 #include "core/events/EventTarget.h" |
| 12 #include "mojo/public/cpp/bindings/associated_binding.h" |
| 13 #include "platform/weborigin/SecurityOrigin.h" |
| 14 |
| 15 namespace blink { |
| 16 |
| 17 class BroadcastChannel final |
| 18 : public EventTargetWithInlineData |
| 19 , public ActiveScriptWrappable |
| 20 , public ContextLifecycleObserver |
| 21 , public webmessaging::mojom::blink::BroadcastChannelClient { |
| 22 DEFINE_WRAPPERTYPEINFO(); |
| 23 USING_GARBAGE_COLLECTED_MIXIN(BroadcastChannel); |
| 24 USING_PRE_FINALIZER(BroadcastChannel, dispose); |
| 25 WTF_MAKE_NONCOPYABLE(BroadcastChannel); |
| 26 public: |
| 27 static BroadcastChannel* create(ExecutionContext*, const String& name, Excep
tionState&); |
| 28 ~BroadcastChannel() override; |
| 29 void dispose(); |
| 30 |
| 31 // IDL |
| 32 String name() const { return m_name; } |
| 33 void postMessage(const ScriptValue&, ExceptionState&); |
| 34 void close(); |
| 35 DEFINE_ATTRIBUTE_EVENT_LISTENER(message); |
| 36 |
| 37 // EventTarget: |
| 38 const AtomicString& interfaceName() const override; |
| 39 ExecutionContext* getExecutionContext() const override { return ContextLifec
ycleObserver::getExecutionContext(); } |
| 40 |
| 41 // ActiveScriptWrappable: |
| 42 bool hasPendingActivity() const override; |
| 43 |
| 44 // ContextLifecycleObserver: |
| 45 void contextDestroyed() override; |
| 46 |
| 47 DECLARE_VIRTUAL_TRACE(); |
| 48 |
| 49 private: |
| 50 BroadcastChannel(ExecutionContext*, const String& name); |
| 51 |
| 52 // webmessaging::mojom::blink::BroadcastChannelClient: |
| 53 void OnMessage(const String& message) override; |
| 54 |
| 55 // Called when the mojo binding disconnects. |
| 56 void onError(); |
| 57 |
| 58 RefPtr<SecurityOrigin> m_origin; |
| 59 String m_name; |
| 60 |
| 61 mojo::AssociatedBinding<webmessaging::mojom::blink::BroadcastChannelClient>
m_binding; |
| 62 webmessaging::mojom::blink::BroadcastChannelClientAssociatedPtr m_remoteClie
nt; |
| 63 }; |
| 64 |
| 65 } // namespace blink |
| 66 |
| 67 #endif // BroadcastChannel_h |
OLD | NEW |