OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef StashedMessagePort_h | 5 #ifndef StashedMessagePort_h |
6 #define StashedMessagePort_h | 6 #define StashedMessagePort_h |
7 | 7 |
8 #include "bindings/core/v8/ScriptWrappable.h" | 8 #include "bindings/core/v8/ScriptWrappable.h" |
9 #include "core/dom/MessagePort.h" | 9 #include "core/dom/MessagePort.h" |
10 #include "modules/ModulesExport.h" | 10 #include "modules/ModulesExport.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 class ExecutionContext; | 13 class ExecutionContext; |
14 class StashedMessagePort; | 14 class StashedMessagePort; |
15 | 15 |
16 using StashedMessagePortArray = HeapVector<Member<StashedMessagePort>, 1>; | 16 using StashedMessagePortArray = HeapVector<Member<StashedMessagePort>, 1>; |
17 | 17 |
18 // Represents a message port that has been stashed. Overrides messageAvailable | 18 // Represents a message port that has been stashed. Overrides messageAvailable |
19 // to dispatch messages as a global event instead of as events on this port. | 19 // to dispatch messages as a global event instead of as events on this port. |
20 class MODULES_EXPORT StashedMessagePort final : public MessagePort { | 20 class MODULES_EXPORT StashedMessagePort final : public MessagePort { |
21 DEFINE_WRAPPERTYPEINFO(); | 21 DEFINE_WRAPPERTYPEINFO(); |
22 WTF_MAKE_NONCOPYABLE(StashedMessagePort); | 22 WTF_MAKE_NONCOPYABLE(StashedMessagePort); |
23 public: | 23 public: |
24 static StashedMessagePort* create(ExecutionContext&, PassOwnPtr<WebMessagePo
rtChannel>, const String& name); | 24 static StashedMessagePort* create(ExecutionContext&, PassOwnPtr<WebMessagePo
rtChannel>, const String& name); |
25 virtual ~StashedMessagePort(); | 25 ~StashedMessagePort() override; |
26 | 26 |
27 static StashedMessagePortArray* toStashedMessagePortArray(ExecutionContext*,
const WebMessagePortChannelArray&, const WebVector<WebString>& channelKeys); | 27 static StashedMessagePortArray* toStashedMessagePortArray(ExecutionContext*,
const WebMessagePortChannelArray&, const WebVector<WebString>& channelKeys); |
28 | 28 |
29 // StashedMessagePort.idl | 29 // StashedMessagePort.idl |
30 String name() const; | 30 String name() const; |
31 | 31 |
32 DEFINE_INLINE_VIRTUAL_TRACE() { MessagePort::trace(visitor); } | 32 DEFINE_INLINE_VIRTUAL_TRACE() { MessagePort::trace(visitor); } |
33 | 33 |
34 private: | 34 private: |
35 StashedMessagePort(ExecutionContext&, PassOwnPtr<WebMessagePortChannel>, con
st String& name); | 35 StashedMessagePort(ExecutionContext&, PassOwnPtr<WebMessagePortChannel>, con
st String& name); |
36 | 36 |
37 void messageAvailable() override; | 37 void messageAvailable() override; |
38 void dispatchMessages(); | 38 void dispatchMessages(); |
39 | 39 |
40 String m_name; | 40 String m_name; |
41 WeakPtrFactory<StashedMessagePort> m_weakFactory; | 41 WeakPtrFactory<StashedMessagePort> m_weakFactory; |
42 }; | 42 }; |
43 | 43 |
44 } // namespace blink | 44 } // namespace blink |
45 | 45 |
46 #endif // StashedMessagePort_h | 46 #endif // StashedMessagePort_h |
OLD | NEW |