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 "core/dom/ContextLifecycleObserver.h" |
| 10 #include "core/events/EventTarget.h" |
| 11 #include "modules/broadcastchannel/BroadcastChannelConnection.h" |
| 12 #include "platform/weborigin/SecurityOrigin.h" |
| 13 |
| 14 namespace blink { |
| 15 |
| 16 class BroadcastChannel final |
| 17 : public EventTargetWithInlineData |
| 18 , public ActiveScriptWrappable |
| 19 , public ContextLifecycleObserver |
| 20 , public BroadcastChannelConnection::Client { |
| 21 DEFINE_WRAPPERTYPEINFO(); |
| 22 USING_GARBAGE_COLLECTED_MIXIN(BroadcastChannel); |
| 23 WTF_MAKE_NONCOPYABLE(BroadcastChannel); |
| 24 public: |
| 25 static BroadcastChannel* create(ExecutionContext*, const String& name, Excep
tionState&); |
| 26 ~BroadcastChannel() override; |
| 27 |
| 28 // IDL |
| 29 void postMessage(const ScriptValue&, ExceptionState&); |
| 30 void close(); |
| 31 DEFINE_ATTRIBUTE_EVENT_LISTENER(message); |
| 32 |
| 33 // BroadcastChannelConnection::Client |
| 34 String name() const override { return m_name; } |
| 35 SecurityOrigin* origin() const override { return m_origin.get(); } |
| 36 void onMessage(const String& message) override; |
| 37 void onError() override; |
| 38 |
| 39 const AtomicString& interfaceName() const override; |
| 40 ExecutionContext* getExecutionContext() const override { return ContextLifec
ycleObserver::getExecutionContext(); } |
| 41 bool hasPendingActivity() const override; |
| 42 |
| 43 DECLARE_VIRTUAL_TRACE(); |
| 44 |
| 45 private: |
| 46 BroadcastChannel(ExecutionContext*, const String& name); |
| 47 |
| 48 RefPtr<SecurityOrigin> m_origin; |
| 49 String m_name; |
| 50 Member<BroadcastChannelConnection> m_connection; |
| 51 }; |
| 52 |
| 53 } // namespace blink |
| 54 |
| 55 #endif // BroadcastChannel_h |
OLD | NEW |