| OLD | NEW |
| 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 bool isQueueEmpty() const override { return m_queue.isEmpty(); } | 132 bool isQueueEmpty() const override { return m_queue.isEmpty(); } |
| 133 void clearQueue() override | 133 void clearQueue() override |
| 134 { | 134 { |
| 135 m_queue.clear(); | 135 m_queue.clear(); |
| 136 m_totalQueueSize = 0; | 136 m_totalQueueSize = 0; |
| 137 } | 137 } |
| 138 | 138 |
| 139 void resolveAllPendingReadsAsDone() override | 139 void resolveAllPendingReadsAsDone() override |
| 140 { | 140 { |
| 141 for (auto& resolver : m_pendingReads) { | 141 for (auto& resolver : m_pendingReads) { |
| 142 ScriptState* scriptState = resolver->scriptState(); | 142 ScriptState* scriptState = resolver->getScriptState(); |
| 143 if (!scriptState->contextIsValid()) | 143 if (!scriptState->contextIsValid()) |
| 144 continue; | 144 continue; |
| 145 ScriptState::Scope scope(scriptState); | 145 ScriptState::Scope scope(scriptState); |
| 146 resolver->resolve(v8IteratorResultDone(scriptState)); | 146 resolver->resolve(v8IteratorResultDone(scriptState)); |
| 147 } | 147 } |
| 148 m_pendingReads.clear(); | 148 m_pendingReads.clear(); |
| 149 } | 149 } |
| 150 | 150 |
| 151 void rejectAllPendingReads(DOMException* reason) override | 151 void rejectAllPendingReads(DOMException* reason) override |
| 152 { | 152 { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 174 if (!enqueuePreliminaryCheck()) | 174 if (!enqueuePreliminaryCheck()) |
| 175 return false; | 175 return false; |
| 176 | 176 |
| 177 if (m_pendingReads.isEmpty()) { | 177 if (m_pendingReads.isEmpty()) { |
| 178 m_queue.append(std::make_pair(chunk, size)); | 178 m_queue.append(std::make_pair(chunk, size)); |
| 179 m_totalQueueSize += size; | 179 m_totalQueueSize += size; |
| 180 return enqueuePostAction(); | 180 return enqueuePostAction(); |
| 181 } | 181 } |
| 182 | 182 |
| 183 ScriptPromiseResolver* resolver = m_pendingReads.takeFirst(); | 183 ScriptPromiseResolver* resolver = m_pendingReads.takeFirst(); |
| 184 ScriptState* scriptState = resolver->scriptState(); | 184 ScriptState* scriptState = resolver->getScriptState(); |
| 185 if (!scriptState->contextIsValid()) | 185 if (!scriptState->contextIsValid()) |
| 186 return false; | 186 return false; |
| 187 ScriptState::Scope scope(scriptState); | 187 ScriptState::Scope scope(scriptState); |
| 188 resolver->resolve(v8IteratorResult(scriptState, chunk)); | 188 resolver->resolve(v8IteratorResult(scriptState, chunk)); |
| 189 return enqueuePostAction(); | 189 return enqueuePostAction(); |
| 190 } | 190 } |
| 191 | 191 |
| 192 template <typename ChunkTypeTraits> | 192 template <typename ChunkTypeTraits> |
| 193 ScriptPromise ReadableStreamImpl<ChunkTypeTraits>::read(ScriptState* scriptState
) | 193 ScriptPromise ReadableStreamImpl<ChunkTypeTraits>::read(ScriptState* scriptState
) |
| 194 { | 194 { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 | 226 |
| 227 setIsDisturbed(); | 227 setIsDisturbed(); |
| 228 queue.swap(m_queue); | 228 queue.swap(m_queue); |
| 229 m_totalQueueSize = 0; | 229 m_totalQueueSize = 0; |
| 230 readInternalPostAction(); | 230 readInternalPostAction(); |
| 231 } | 231 } |
| 232 | 232 |
| 233 } // namespace blink | 233 } // namespace blink |
| 234 | 234 |
| 235 #endif // ReadableStreamImpl_h | 235 #endif // ReadableStreamImpl_h |
| OLD | NEW |