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 const AtomicString& interfaceName() const override; | |
38 ExecutionContext* getExecutionContext() const override { return ContextLifec ycleObserver::getExecutionContext(); } | |
kinuko
2016/06/09 09:14:58
do we need this override??
Marijn Kruisselbrink
2016/06/22 18:46:57
Yes, EventTarget has a pure virtual getExecutionCo
| |
39 bool hasPendingActivity() const override; | |
40 | |
41 void contextDestroyed() override; | |
42 | |
43 DECLARE_VIRTUAL_TRACE(); | |
44 | |
45 private: | |
46 BroadcastChannel(ExecutionContext*, const String& name); | |
47 | |
48 // webmessaging::mojom::blink::BroadcastChannelClient: | |
49 void OnMessage(const String& message) override; | |
50 | |
51 // Called when the mojo binding disconnects. | |
52 void onError(); | |
53 | |
54 RefPtr<SecurityOrigin> m_origin; | |
55 String m_name; | |
56 | |
57 mojo::AssociatedBinding<webmessaging::mojom::blink::BroadcastChannelClient> m_binding; | |
58 webmessaging::mojom::blink::BroadcastChannelClientAssociatedPtr m_remoteClie nt; | |
59 }; | |
60 | |
61 } // namespace blink | |
62 | |
63 #endif // BroadcastChannel_h | |
OLD | NEW |