Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Unified Diff: third_party/WebKit/Source/modules/broadcastchannel/BroadcastChannel.h

Issue 2004643002: Implement BroadcastChannel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address dcheng's comments Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/broadcastchannel/BroadcastChannel.h
diff --git a/third_party/WebKit/Source/modules/broadcastchannel/BroadcastChannel.h b/third_party/WebKit/Source/modules/broadcastchannel/BroadcastChannel.h
new file mode 100644
index 0000000000000000000000000000000000000000..7ebde2dc7b9105b7ffb5e6e9feaa3474b85556b0
--- /dev/null
+++ b/third_party/WebKit/Source/modules/broadcastchannel/BroadcastChannel.h
@@ -0,0 +1,67 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BroadcastChannel_h
+#define BroadcastChannel_h
+
+#include "bindings/core/v8/ActiveScriptWrappable.h"
+#include "components/webmessaging/public/interfaces/broadcast_channel.mojom-blink.h"
+#include "core/dom/ContextLifecycleObserver.h"
+#include "core/events/EventTarget.h"
+#include "mojo/public/cpp/bindings/associated_binding.h"
+#include "platform/weborigin/SecurityOrigin.h"
+
+namespace blink {
+
+class BroadcastChannel final
+ : public EventTargetWithInlineData
+ , public ActiveScriptWrappable
+ , public ContextLifecycleObserver
+ , public webmessaging::mojom::blink::BroadcastChannelClient {
+ DEFINE_WRAPPERTYPEINFO();
+ USING_GARBAGE_COLLECTED_MIXIN(BroadcastChannel);
+ USING_PRE_FINALIZER(BroadcastChannel, dispose);
+ WTF_MAKE_NONCOPYABLE(BroadcastChannel);
+public:
+ static BroadcastChannel* create(ExecutionContext*, const String& name, ExceptionState&);
+ ~BroadcastChannel() override;
+ void dispose();
+
+ // IDL
+ String name() const { return m_name; }
+ void postMessage(const ScriptValue&, ExceptionState&);
+ void close();
+ DEFINE_ATTRIBUTE_EVENT_LISTENER(message);
+
+ // EventTarget:
+ const AtomicString& interfaceName() const override;
+ ExecutionContext* getExecutionContext() const override { return ContextLifecycleObserver::getExecutionContext(); }
+
+ // ActiveScriptWrappable:
+ bool hasPendingActivity() const override;
+
+ // ContextLifecycleObserver:
+ void contextDestroyed() override;
+
+ DECLARE_VIRTUAL_TRACE();
+
+private:
+ BroadcastChannel(ExecutionContext*, const String& name);
+
+ // webmessaging::mojom::blink::BroadcastChannelClient:
+ void OnMessage(const String& message) override;
+
+ // Called when the mojo binding disconnects.
+ void onError();
+
+ RefPtr<SecurityOrigin> m_origin;
+ String m_name;
+
+ mojo::AssociatedBinding<webmessaging::mojom::blink::BroadcastChannelClient> m_binding;
+ webmessaging::mojom::blink::BroadcastChannelClientAssociatedPtr m_remoteClient;
+};
+
+} // namespace blink
+
+#endif // BroadcastChannel_h
« no previous file with comments | « third_party/WebKit/Source/modules/BUILD.gn ('k') | third_party/WebKit/Source/modules/broadcastchannel/BroadcastChannel.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698