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

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

Issue 1418813004: [Fetch API] Reflect spec changes of bodyUsed property (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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"
11 #include "bindings/core/v8/ScriptState.h" 11 #include "bindings/core/v8/ScriptState.h"
12 #include "bindings/core/v8/ScriptValue.h" 12 #include "bindings/core/v8/ScriptValue.h"
13 #include "bindings/core/v8/ToV8.h"
13 #include "bindings/core/v8/V8ArrayBuffer.h" 14 #include "bindings/core/v8/V8ArrayBuffer.h"
14 #include "bindings/core/v8/V8Binding.h" 15 #include "bindings/core/v8/V8Binding.h"
15 #include "bindings/core/v8/V8IteratorResultValue.h" 16 #include "bindings/core/v8/V8IteratorResultValue.h"
16 #include "core/dom/DOMArrayBuffer.h" 17 #include "core/dom/DOMArrayBuffer.h"
17 #include "core/dom/DOMArrayBufferView.h" 18 #include "core/dom/DOMArrayBufferView.h"
18 #include "core/dom/DOMException.h" 19 #include "core/dom/DOMException.h"
19 #include "core/streams/ReadableStream.h" 20 #include "core/streams/ReadableStream.h"
20 #include "wtf/Deque.h" 21 #include "wtf/Deque.h"
21 #include "wtf/RefPtr.h" 22 #include "wtf/RefPtr.h"
22 #include "wtf/text/WTFString.h" 23 #include "wtf/text/WTFString.h"
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 if (!scriptState->contextIsValid()) 185 if (!scriptState->contextIsValid())
185 return false; 186 return false;
186 ScriptState::Scope scope(scriptState); 187 ScriptState::Scope scope(scriptState);
187 resolver->resolve(v8IteratorResult(scriptState, chunk)); 188 resolver->resolve(v8IteratorResult(scriptState, chunk));
188 return enqueuePostAction(); 189 return enqueuePostAction();
189 } 190 }
190 191
191 template <typename ChunkTypeTraits> 192 template <typename ChunkTypeTraits>
192 ScriptPromise ReadableStreamImpl<ChunkTypeTraits>::read(ScriptState* scriptState ) 193 ScriptPromise ReadableStreamImpl<ChunkTypeTraits>::read(ScriptState* scriptState )
193 { 194 {
195 if (stateInternal() == Closed)
196 return ScriptPromise::cast(scriptState, v8IteratorResultDone(scriptState ));
197 if (stateInternal() == Errored)
198 return ScriptPromise::reject(scriptState, toV8(storedException(), script State->context()->Global(), scriptState->isolate()));
199
194 ASSERT(stateInternal() == Readable); 200 ASSERT(stateInternal() == Readable);
195 setIsDisturbed(); 201 setIsDisturbed();
196 if (m_queue.isEmpty()) { 202 if (m_queue.isEmpty()) {
197 m_pendingReads.append(ScriptPromiseResolver::create(scriptState)); 203 m_pendingReads.append(ScriptPromiseResolver::create(scriptState));
198 ScriptPromise promise = m_pendingReads.last()->promise(); 204 ScriptPromise promise = m_pendingReads.last()->promise();
199 readInternalPostAction(); 205 readInternalPostAction();
200 return promise; 206 return promise;
201 } 207 }
202 208
203 auto pair = m_queue.takeFirst(); 209 auto pair = m_queue.takeFirst();
(...skipping 16 matching lines...) Expand all
220 226
221 setIsDisturbed(); 227 setIsDisturbed();
222 queue.swap(m_queue); 228 queue.swap(m_queue);
223 m_totalQueueSize = 0; 229 m_totalQueueSize = 0;
224 readInternalPostAction(); 230 readInternalPostAction();
225 } 231 }
226 232
227 } // namespace blink 233 } // namespace blink
228 234
229 #endif // ReadableStreamImpl_h 235 #endif // ReadableStreamImpl_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698