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

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

Issue 1008533005: Initial implementation of stashed message ports, blink side (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 5 years, 7 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
« no previous file with comments | « no previous file | Source/core/dom/MessagePort.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 WillBeHeapVector<RefPtrWillBeMember<MessagePort>, 1> MessagePortArray; 53 typedef WillBeHeapVector<RefPtrWillBeMember<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 final 58 class CORE_EXPORT MessagePort
59 : public EventTargetWithInlineData 59 : public EventTargetWithInlineData
60 , public RefCountedWillBeNoBase<MessagePort> 60 , public RefCountedWillBeNoBase<MessagePort>
61 , public ActiveDOMObject 61 , public ActiveDOMObject
62 , public WebMessagePortChannelClient { 62 , public WebMessagePortChannelClient {
63 DEFINE_WRAPPERTYPEINFO(); 63 DEFINE_WRAPPERTYPEINFO();
64 REFCOUNTED_EVENT_TARGET(MessagePort); 64 REFCOUNTED_EVENT_TARGET(MessagePort);
65 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(MessagePort); 65 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(MessagePort);
66 public: 66 public:
67 static PassRefPtrWillBeRawPtr<MessagePort> create(ExecutionContext&); 67 static PassRefPtrWillBeRawPtr<MessagePort> create(ExecutionContext&);
68 virtual ~MessagePort(); 68 virtual ~MessagePort();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 EventListener* onmessage() { return getAttributeEventListener(EventTypeNames ::message); } 102 EventListener* onmessage() { return getAttributeEventListener(EventTypeNames ::message); }
103 103
104 // A port starts out its life entangled, and remains entangled until it is c losed or is cloned. 104 // A port starts out its life entangled, and remains entangled until it is c losed or is cloned.
105 bool isEntangled() const { return !m_closed && !isNeutered(); } 105 bool isEntangled() const { return !m_closed && !isNeutered(); }
106 106
107 // A port gets neutered when it is transferred to a new owner via postMessag e(). 107 // A port gets neutered when it is transferred to a new owner via postMessag e().
108 bool isNeutered() const { return !m_entangledChannel; } 108 bool isNeutered() const { return !m_entangledChannel; }
109 109
110 DECLARE_VIRTUAL_TRACE(); 110 DECLARE_VIRTUAL_TRACE();
111 111
112 protected:
113 explicit MessagePort(ExecutionContext&);
114 bool tryGetMessage(RefPtr<SerializedScriptValue>& message, OwnPtr<MessagePor tChannelArray>& channels);
115
112 private: 116 private:
113 explicit MessagePort(ExecutionContext&);
114
115 // WebMessagePortChannelClient implementation. 117 // WebMessagePortChannelClient implementation.
116 virtual void messageAvailable() override; 118 virtual void messageAvailable() override;
117 virtual v8::Isolate* scriptIsolate() override; 119 virtual v8::Isolate* scriptIsolate() override;
118 virtual v8::Local<v8::Context> scriptContextForMessageConversion() override; 120 virtual v8::Local<v8::Context> scriptContextForMessageConversion() override;
119 void dispatchMessages(); 121 void dispatchMessages();
120 122
121 OwnPtr<WebMessagePortChannel> m_entangledChannel; 123 OwnPtr<WebMessagePortChannel> m_entangledChannel;
122 124
123 bool m_started; 125 bool m_started;
124 bool m_closed; 126 bool m_closed;
125 127
126 WeakPtrFactory<MessagePort> m_weakFactory; 128 WeakPtrFactory<MessagePort> m_weakFactory;
127 129
128 RefPtr<ScriptState> m_scriptStateForConversion; 130 RefPtr<ScriptState> m_scriptStateForConversion;
129 }; 131 };
130 132
131 } // namespace blink 133 } // namespace blink
132 134
133 #endif // MessagePort_h 135 #endif // MessagePort_h
OLDNEW
« no previous file with comments | « no previous file | Source/core/dom/MessagePort.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698