| 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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 , m_opaque(false) | |
| 294 { | 293 { |
| 295 suspendIfNeeded(); | 294 suspendIfNeeded(); |
| 296 } | 295 } |
| 297 | 296 |
| 298 ScriptPromise Body::rejectInvalidConsumption(ScriptState* scriptState) | 297 ScriptPromise Body::rejectInvalidConsumption(ScriptState* scriptState) |
| 299 { | 298 { |
| 300 if (m_opaque) | |
| 301 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr
ror(scriptState->isolate(), "The body is opaque.")); | |
| 302 if (isBodyLocked() || bodyUsed()) | 299 if (isBodyLocked() || bodyUsed()) |
| 303 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr
ror(scriptState->isolate(), "Already read")); | 300 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr
ror(scriptState->isolate(), "Already read")); |
| 304 return ScriptPromise(); | 301 return ScriptPromise(); |
| 305 } | 302 } |
| 306 | 303 |
| 307 } // namespace blink | 304 } // namespace blink |
| OLD | NEW |