| Index: third_party/WebKit/Source/modules/fetch/Body.cpp
|
| diff --git a/third_party/WebKit/Source/modules/fetch/Body.cpp b/third_party/WebKit/Source/modules/fetch/Body.cpp
|
| index 449777c5959bc57132e6547134781a49a922669c..55366f74347d7195ea650b5900de250c0ed78206 100644
|
| --- a/third_party/WebKit/Source/modules/fetch/Body.cpp
|
| +++ b/third_party/WebKit/Source/modules/fetch/Body.cpp
|
| @@ -104,7 +104,7 @@ public:
|
|
|
| ScriptPromise Body::arrayBuffer(ScriptState* scriptState)
|
| {
|
| - if (bodyUsed())
|
| + if (isBodyLocked() || bodyUsed())
|
| return ScriptPromise::reject(scriptState, V8ThrowException::createTypeError(scriptState->isolate(), "Already read"));
|
|
|
| // When the main thread sends a V8::TerminateExecution() signal to a worker
|
| @@ -128,7 +128,7 @@ ScriptPromise Body::arrayBuffer(ScriptState* scriptState)
|
|
|
| ScriptPromise Body::blob(ScriptState* scriptState)
|
| {
|
| - if (bodyUsed())
|
| + if (isBodyLocked() || bodyUsed())
|
| return ScriptPromise::reject(scriptState, V8ThrowException::createTypeError(scriptState->isolate(), "Already read"));
|
|
|
| // See above comment.
|
| @@ -150,7 +150,7 @@ ScriptPromise Body::blob(ScriptState* scriptState)
|
|
|
| ScriptPromise Body::json(ScriptState* scriptState)
|
| {
|
| - if (bodyUsed())
|
| + if (isBodyLocked() || bodyUsed())
|
| return ScriptPromise::reject(scriptState, V8ThrowException::createTypeError(scriptState->isolate(), "Already read"));
|
|
|
| // See above comment.
|
| @@ -169,7 +169,7 @@ ScriptPromise Body::json(ScriptState* scriptState)
|
|
|
| ScriptPromise Body::text(ScriptState* scriptState)
|
| {
|
| - if (bodyUsed())
|
| + if (isBodyLocked() || bodyUsed())
|
| return ScriptPromise::reject(scriptState, V8ThrowException::createTypeError(scriptState->isolate(), "Already read"));
|
|
|
| // See above comment.
|
| @@ -188,13 +188,23 @@ ScriptPromise Body::text(ScriptState* scriptState)
|
|
|
| ReadableByteStream* Body::body()
|
| {
|
| - UseCounter::count(executionContext(), UseCounter::FetchBodyStream);
|
| return bodyBuffer() ? bodyBuffer()->stream() : nullptr;
|
| }
|
|
|
| +ReadableByteStream* Body::bodyWithUseCounter()
|
| +{
|
| + UseCounter::count(executionContext(), UseCounter::FetchBodyStream);
|
| + return body();
|
| +}
|
| +
|
| bool Body::bodyUsed()
|
| {
|
| - return m_bodyPassed || (body() && body()->isLocked());
|
| + return body() && body()->isDisturbed();
|
| +}
|
| +
|
| +bool Body::isBodyLocked()
|
| +{
|
| + return body() && body()->isLocked();
|
| }
|
|
|
| bool Body::hasPendingActivity() const
|
| @@ -206,7 +216,7 @@ bool Body::hasPendingActivity() const
|
| return bodyBuffer()->hasPendingActivity();
|
| }
|
|
|
| -Body::Body(ExecutionContext* context) : ActiveDOMObject(context), m_bodyPassed(false)
|
| +Body::Body(ExecutionContext* context) : ActiveDOMObject(context) {}
|
| {
|
| suspendIfNeeded();
|
| }
|
|
|