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

Side by Side Diff: Source/core/streams/ReadableStreamImpl.h

Issue 1233173002: Have ScriptPromiseResolver on the Oilpan heap always. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: tidy unit tests Created 5 years, 5 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 ReadableStreamImpl_h 5 #ifndef ReadableStreamImpl_h
6 #define ReadableStreamImpl_h 6 #define ReadableStreamImpl_h
7 7
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "bindings/core/v8/ScriptPromise.h" 9 #include "bindings/core/v8/ScriptPromise.h"
10 #include "bindings/core/v8/ScriptPromiseResolver.h" 10 #include "bindings/core/v8/ScriptPromiseResolver.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 111
112 // This function is intended to be used by internal code to withdraw 112 // This function is intended to be used by internal code to withdraw
113 // queued data. This pulls all data from this stream's queue, but 113 // queued data. This pulls all data from this stream's queue, but
114 // ReadableStream public APIs can work with the behavior (i.e. it behaves 114 // ReadableStream public APIs can work with the behavior (i.e. it behaves
115 // as if multiple read-one-buffer calls were made). 115 // as if multiple read-one-buffer calls were made).
116 void readInternal(Deque<std::pair<typename ChunkTypeTraits::HoldType, size_t >>& queue); 116 void readInternal(Deque<std::pair<typename ChunkTypeTraits::HoldType, size_t >>& queue);
117 117
118 DEFINE_INLINE_VIRTUAL_TRACE() 118 DEFINE_INLINE_VIRTUAL_TRACE()
119 { 119 {
120 visitor->trace(m_strategy); 120 visitor->trace(m_strategy);
121 #if ENABLE(OILPAN)
122 visitor->trace(m_pendingReads); 121 visitor->trace(m_pendingReads);
123 #endif
124 ReadableStream::trace(visitor); 122 ReadableStream::trace(visitor);
125 } 123 }
126 124
127 private: 125 private:
128 #if ENABLE(OILPAN)
129 using PendingReads = HeapDeque<Member<ScriptPromiseResolver>>; 126 using PendingReads = HeapDeque<Member<ScriptPromiseResolver>>;
130 #else
131 using PendingReads = Deque<RefPtr<ScriptPromiseResolver>>;
132 #endif
133 127
134 // ReadableStream methods 128 // ReadableStream methods
135 bool isQueueEmpty() const override { return m_queue.isEmpty(); } 129 bool isQueueEmpty() const override { return m_queue.isEmpty(); }
136 void clearQueue() override 130 void clearQueue() override
137 { 131 {
138 m_queue.clear(); 132 m_queue.clear();
139 m_totalQueueSize = 0; 133 m_totalQueueSize = 0;
140 } 134 }
141 135
142 void resolveAllPendingReadsAsDone() override 136 void resolveAllPendingReadsAsDone() override
(...skipping 30 matching lines...) Expand all
173 size_t size = m_strategy->size(chunk, this); 167 size_t size = m_strategy->size(chunk, this);
174 if (!enqueuePreliminaryCheck()) 168 if (!enqueuePreliminaryCheck())
175 return false; 169 return false;
176 170
177 if (m_pendingReads.isEmpty()) { 171 if (m_pendingReads.isEmpty()) {
178 m_queue.append(std::make_pair(chunk, size)); 172 m_queue.append(std::make_pair(chunk, size));
179 m_totalQueueSize += size; 173 m_totalQueueSize += size;
180 return enqueuePostAction(); 174 return enqueuePostAction();
181 } 175 }
182 176
183 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = m_pendingReads.takeFirs t(); 177 ScriptPromiseResolver* resolver = m_pendingReads.takeFirst();
184 ScriptState* scriptState = resolver->scriptState(); 178 ScriptState* scriptState = resolver->scriptState();
haraken 2015/07/17 01:40:35 Not related to this CL, we should have: if (!sc
sof 2015/07/17 09:43:26 Done, here & in resolveAllPendingReadsAsDone() yh
yhirano 2015/07/17 13:53:41 haraken@: Is it guaranteed that the document is st
haraken 2015/07/18 07:10:27 It is guaranteed for a document that is associated
185 ScriptState::Scope scope(scriptState); 179 ScriptState::Scope scope(scriptState);
186 resolver->resolve(v8IteratorResult(scriptState, chunk)); 180 resolver->resolve(v8IteratorResult(scriptState, chunk));
187 return enqueuePostAction(); 181 return enqueuePostAction();
188 } 182 }
189 183
190 template <typename ChunkTypeTraits> 184 template <typename ChunkTypeTraits>
191 ScriptPromise ReadableStreamImpl<ChunkTypeTraits>::read(ScriptState* scriptState ) 185 ScriptPromise ReadableStreamImpl<ChunkTypeTraits>::read(ScriptState* scriptState )
192 { 186 {
193 ASSERT(stateInternal() == Readable); 187 ASSERT(stateInternal() == Readable);
194 if (m_queue.isEmpty()) { 188 if (m_queue.isEmpty()) {
(...skipping 22 matching lines...) Expand all
217 ASSERT(queue.isEmpty()); 211 ASSERT(queue.isEmpty());
218 212
219 queue.swap(m_queue); 213 queue.swap(m_queue);
220 m_totalQueueSize = 0; 214 m_totalQueueSize = 0;
221 readInternalPostAction(); 215 readInternalPostAction();
222 } 216 }
223 217
224 } // namespace blink 218 } // namespace blink
225 219
226 #endif // ReadableStreamImpl_h 220 #endif // ReadableStreamImpl_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698