blob: 62e35c9fc05fc84e95221ddedf5f2d8d0ad7414a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
// 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 THIRD_PARTY_BLINK_RENDERER_MODULES_BROADCASTCHANNEL_BROADCAST_CHANNEL_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_BROADCASTCHANNEL_BROADCAST_CHANNEL_H_
#include "base/macros.h"
#include "mojo/public/cpp/bindings/associated_binding.h"
#include "third_party/blink/public/mojom/broadcastchannel/broadcast_channel.mojom-blink.h"
#include "third_party/blink/renderer/bindings/core/v8/active_script_wrappable.h"
#include "third_party/blink/renderer/core/dom/events/event_target.h"
#include "third_party/blink/renderer/core/execution_context/context_lifecycle_observer.h"
#include "third_party/blink/renderer/platform/weborigin/security_origin.h"
namespace blink {
class ScriptValue;
class BroadcastChannel final : public EventTargetWithInlineData,
public ActiveScriptWrappable<BroadcastChannel>,
public ContextLifecycleObserver,
public mojom::blink::BroadcastChannelClient {
DEFINE_WRAPPERTYPEINFO();
USING_GARBAGE_COLLECTED_MIXIN(BroadcastChannel);
USING_PRE_FINALIZER(BroadcastChannel, Dispose);
public:
static BroadcastChannel* Create(ExecutionContext*,
const String& name,
ExceptionState&);
BroadcastChannel(ExecutionContext*, const String& name);
~BroadcastChannel() override;
void Dispose();
// IDL
String name() const { return name_; }
void postMessage(const ScriptValue&, ExceptionState&);
void close();
DEFINE_ATTRIBUTE_EVENT_LISTENER(message, kMessage)
DEFINE_ATTRIBUTE_EVENT_LISTENER(messageerror, kMessageerror)
// EventTarget:
const AtomicString& InterfaceName() const override;
ExecutionContext* GetExecutionContext() const override {
return ContextLifecycleObserver::GetExecutionContext();
}
// ScriptWrappable:
bool HasPendingActivity() const override;
// ContextLifecycleObserver:
void ContextDestroyed(ExecutionContext*) override;
void Trace(blink::Visitor*) override;
private:
// mojom::blink::BroadcastChannelClient:
void OnMessage(BlinkCloneableMessage) override;
// Called when the mojo binding disconnects.
void OnError();
scoped_refptr<const SecurityOrigin> origin_;
String name_;
mojo::AssociatedBinding<mojom::blink::BroadcastChannelClient> binding_;
mojom::blink::BroadcastChannelClientAssociatedPtr remote_client_;
DISALLOW_COPY_AND_ASSIGN(BroadcastChannel);
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_BROADCASTCHANNEL_BROADCAST_CHANNEL_H_
|