| 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 #include "modules/fetch/Body.h" | 5 #include "modules/fetch/Body.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
| 8 #include "bindings/core/v8/ScriptPromiseResolver.h" | 8 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 9 #include "bindings/core/v8/ScriptState.h" | 9 #include "bindings/core/v8/ScriptState.h" |
| 10 #include "bindings/core/v8/V8ArrayBuffer.h" | 10 #include "bindings/core/v8/V8ArrayBuffer.h" |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 if (bodyUsed() || isBodyLocked() || !bodyBuffer()) | 263 if (bodyUsed() || isBodyLocked() || !bodyBuffer()) |
| 264 return ScriptValue(scriptState, v8::Undefined(scriptState->isolate())); | 264 return ScriptValue(scriptState, v8::Undefined(scriptState->isolate())); |
| 265 OwnPtr<FetchDataConsumerHandle> handle = bodyBuffer()->releaseHandle(scriptS
tate->getExecutionContext()); | 265 OwnPtr<FetchDataConsumerHandle> handle = bodyBuffer()->releaseHandle(scriptS
tate->getExecutionContext()); |
| 266 return ReadableStreamOperations::createReadableStream(scriptState, | 266 return ReadableStreamOperations::createReadableStream(scriptState, |
| 267 new UnderlyingSourceFromDataConsumerHandle(scriptState, handle.release()
), | 267 new UnderlyingSourceFromDataConsumerHandle(scriptState, handle.release()
), |
| 268 ScriptValue(scriptState, v8::Undefined(scriptState->isolate()))); | 268 ScriptValue(scriptState, v8::Undefined(scriptState->isolate()))); |
| 269 } | 269 } |
| 270 | 270 |
| 271 bool Body::bodyUsed() | 271 bool Body::bodyUsed() |
| 272 { | 272 { |
| 273 return body() && body()->isDisturbed(); | 273 return bodyBuffer() && bodyBuffer()->isStreamDisturbed(); |
| 274 } | 274 } |
| 275 | 275 |
| 276 bool Body::isBodyLocked() | 276 bool Body::isBodyLocked() |
| 277 { | 277 { |
| 278 return body() && body()->isLocked(); | 278 return bodyBuffer() && bodyBuffer()->isStreamLocked(); |
| 279 } | 279 } |
| 280 | 280 |
| 281 bool Body::hasPendingActivity() const | 281 bool Body::hasPendingActivity() const |
| 282 { | 282 { |
| 283 if (getExecutionContext()->activeDOMObjectsAreStopped()) | 283 if (getExecutionContext()->activeDOMObjectsAreStopped()) |
| 284 return false; | 284 return false; |
| 285 if (!bodyBuffer()) | 285 if (!bodyBuffer()) |
| 286 return false; | 286 return false; |
| 287 return bodyBuffer()->hasPendingActivity(); | 287 return bodyBuffer()->hasPendingActivity(); |
| 288 } | 288 } |
| 289 | 289 |
| 290 Body::Body(ExecutionContext* context) | 290 Body::Body(ExecutionContext* context) |
| 291 : ActiveScriptWrappable(this) | 291 : ActiveScriptWrappable(this) |
| 292 , ActiveDOMObject(context) | 292 , ActiveDOMObject(context) |
| 293 { | 293 { |
| 294 suspendIfNeeded(); | 294 suspendIfNeeded(); |
| 295 } | 295 } |
| 296 | 296 |
| 297 ScriptPromise Body::rejectInvalidConsumption(ScriptState* scriptState) | 297 ScriptPromise Body::rejectInvalidConsumption(ScriptState* scriptState) |
| 298 { | 298 { |
| 299 if (isBodyLocked() || bodyUsed()) | 299 if (isBodyLocked() || bodyUsed()) |
| 300 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr
ror(scriptState->isolate(), "Already read")); | 300 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr
ror(scriptState->isolate(), "Already read")); |
| 301 return ScriptPromise(); | 301 return ScriptPromise(); |
| 302 } | 302 } |
| 303 | 303 |
| 304 } // namespace blink | 304 } // namespace blink |
| OLD | NEW |