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

Side by Side Diff: third_party/WebKit/Source/core/dom/MessagePort.h

Issue 1750453002: Reduce ActiveDOMObjects from core/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 10 matching lines...) Expand all
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 * 24 *
25 */ 25 */
26 26
27 #ifndef MessagePort_h 27 #ifndef MessagePort_h
28 #define MessagePort_h 28 #define MessagePort_h
29 29
30 #include "core/CoreExport.h" 30 #include "core/CoreExport.h"
31 #include "core/dom/ActiveDOMObject.h" 31 #include "core/dom/ContextLifecycleObserver.h"
32 #include "core/events/EventListener.h" 32 #include "core/events/EventListener.h"
33 #include "core/events/EventTarget.h" 33 #include "core/events/EventTarget.h"
34 #include "public/platform/WebMessagePortChannel.h" 34 #include "public/platform/WebMessagePortChannel.h"
35 #include "public/platform/WebMessagePortChannelClient.h" 35 #include "public/platform/WebMessagePortChannelClient.h"
36 #include "wtf/OwnPtr.h" 36 #include "wtf/OwnPtr.h"
37 #include "wtf/PassOwnPtr.h" 37 #include "wtf/PassOwnPtr.h"
38 #include "wtf/PassRefPtr.h" 38 #include "wtf/PassRefPtr.h"
39 #include "wtf/RefCounted.h" 39 #include "wtf/RefCounted.h"
40 #include "wtf/RefPtr.h" 40 #include "wtf/RefPtr.h"
41 #include "wtf/Vector.h" 41 #include "wtf/Vector.h"
42 #include "wtf/WeakPtr.h" 42 #include "wtf/WeakPtr.h"
43 43
44 namespace blink { 44 namespace blink {
45 45
46 class ExceptionState; 46 class ExceptionState;
47 class ExecutionContext; 47 class ExecutionContext;
48 class MessagePort; 48 class MessagePort;
49 class ScriptState; 49 class ScriptState;
50 class SerializedScriptValue; 50 class SerializedScriptValue;
51 51
52 // The overwhelmingly common case is sending a single port, so handle that effic iently with an inline buffer of size 1. 52 // The overwhelmingly common case is sending a single port, so handle that effic iently with an inline buffer of size 1.
53 typedef HeapVector<Member<MessagePort>, 1> MessagePortArray; 53 typedef HeapVector<Member<MessagePort>, 1> MessagePortArray;
54 54
55 // Not to be confused with WebMessagePortChannelArray; this one uses Vector and OwnPtr instead of WebVector and raw pointers. 55 // Not to be confused with WebMessagePortChannelArray; this one uses Vector and OwnPtr instead of WebVector and raw pointers.
56 typedef Vector<OwnPtr<WebMessagePortChannel>, 1> MessagePortChannelArray; 56 typedef Vector<OwnPtr<WebMessagePortChannel>, 1> MessagePortChannelArray;
57 57
58 class CORE_EXPORT MessagePort 58 class CORE_EXPORT MessagePort
59 : public RefCountedGarbageCollectedEventTargetWithInlineData<MessagePort> 59 : public RefCountedGarbageCollectedEventTargetWithInlineData<MessagePort>
60 , public ActiveDOMObject 60 , public ContextLifecycleObserver
61 , public WebMessagePortChannelClient { 61 , public WebMessagePortChannelClient {
62 DEFINE_WRAPPERTYPEINFO(); 62 DEFINE_WRAPPERTYPEINFO();
63 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(MessagePort); 63 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(MessagePort);
64 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(MessagePort); 64 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(MessagePort);
65 public: 65 public:
66 static MessagePort* create(ExecutionContext&); 66 static MessagePort* create(ExecutionContext&);
67 ~MessagePort() override; 67 ~MessagePort() override;
68 68
69 void postMessage(ExecutionContext*, PassRefPtr<SerializedScriptValue> messag e, const MessagePortArray*, ExceptionState&); 69 void postMessage(ExecutionContext*, PassRefPtr<SerializedScriptValue> messag e, const MessagePortArray*, ExceptionState&);
70 70
71 void start(); 71 void start();
72 void close(); 72 void close();
73 73
74 void entangle(PassOwnPtr<WebMessagePortChannel>); 74 void entangle(PassOwnPtr<WebMessagePortChannel>);
75 PassOwnPtr<WebMessagePortChannel> disentangle(); 75 PassOwnPtr<WebMessagePortChannel> disentangle();
76 76
77 static PassOwnPtr<WebMessagePortChannelArray> toWebMessagePortChannelArray(P assOwnPtr<MessagePortChannelArray>); 77 static PassOwnPtr<WebMessagePortChannelArray> toWebMessagePortChannelArray(P assOwnPtr<MessagePortChannelArray>);
78 static MessagePortArray* toMessagePortArray(ExecutionContext*, const WebMess agePortChannelArray&); 78 static MessagePortArray* toMessagePortArray(ExecutionContext*, const WebMess agePortChannelArray&);
79 79
80 // Returns 0 if there is an exception, or if the passed-in array is 0/empty. 80 // Returns 0 if there is an exception, or if the passed-in array is 0/empty.
81 static PassOwnPtr<MessagePortChannelArray> disentanglePorts(ExecutionContext *, const MessagePortArray*, ExceptionState&); 81 static PassOwnPtr<MessagePortChannelArray> disentanglePorts(ExecutionContext *, const MessagePortArray*, ExceptionState&);
82 82
83 // Returns 0 if the passed array is 0/empty. 83 // Returns 0 if the passed array is 0/empty.
84 static MessagePortArray* entanglePorts(ExecutionContext&, PassOwnPtr<Message PortChannelArray>); 84 static MessagePortArray* entanglePorts(ExecutionContext&, PassOwnPtr<Message PortChannelArray>);
85 85
86 bool started() const { return m_started; } 86 bool started() const { return m_started; }
87 87
88 const AtomicString& interfaceName() const override; 88 const AtomicString& interfaceName() const override;
89 ExecutionContext* executionContext() const override { return ActiveDOMObject ::executionContext(); } 89 ExecutionContext* executionContext() const override { return ContextLifecycl eObserver::executionContext(); }
90 MessagePort* toMessagePort() override { return this; } 90 MessagePort* toMessagePort() override { return this; }
91 91
92 // ActiveDOMObject implementation.
93 bool hasPendingActivity() const override; 92 bool hasPendingActivity() const override;
94 void stop() override { close(); } 93 void contextDestroyed() override { close(); }
95 94
96 void setOnmessage(PassRefPtrWillBeRawPtr<EventListener> listener) 95 void setOnmessage(PassRefPtrWillBeRawPtr<EventListener> listener)
97 { 96 {
98 setAttributeEventListener(EventTypeNames::message, listener); 97 setAttributeEventListener(EventTypeNames::message, listener);
99 start(); 98 start();
100 } 99 }
101 EventListener* onmessage() { return getAttributeEventListener(EventTypeNames ::message); } 100 EventListener* onmessage() { return getAttributeEventListener(EventTypeNames ::message); }
102 101
103 // A port starts out its life entangled, and remains entangled until it is c losed or is cloned. 102 // A port starts out its life entangled, and remains entangled until it is c losed or is cloned.
104 bool isEntangled() const { return !m_closed && !isNeutered(); } 103 bool isEntangled() const { return !m_closed && !isNeutered(); }
(...skipping 20 matching lines...) Expand all
125 bool m_closed; 124 bool m_closed;
126 125
127 WeakPtrFactory<MessagePort> m_weakFactory; 126 WeakPtrFactory<MessagePort> m_weakFactory;
128 127
129 RefPtr<ScriptState> m_scriptStateForConversion; 128 RefPtr<ScriptState> m_scriptStateForConversion;
130 }; 129 };
131 130
132 } // namespace blink 131 } // namespace blink
133 132
134 #endif // MessagePort_h 133 #endif // MessagePort_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698