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

Unified Diff: third_party/WebKit/Source/modules/fetch/Body.cpp

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, 1 month 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 side-by-side diff with in-line comments
Download patch
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 3e489a74238ec647a95d806020db87f2bc3fe303..8ee37de5df3d1856d7e9ddc29b1ea509a09ba18c 100644
--- a/third_party/WebKit/Source/modules/fetch/Body.cpp
+++ b/third_party/WebKit/Source/modules/fetch/Body.cpp
@@ -192,13 +192,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
@@ -210,7 +220,7 @@ bool Body::hasPendingActivity() const
return bodyBuffer()->hasPendingActivity();
}
-Body::Body(ExecutionContext* context) : ActiveDOMObject(context), m_bodyPassed(false), m_opaque(false)
+Body::Body(ExecutionContext* context) : ActiveDOMObject(context), m_opaque(false)
{
suspendIfNeeded();
}
@@ -219,7 +229,7 @@ ScriptPromise Body::rejectInvalidConsumption(ScriptState* scriptState)
{
if (m_opaque)
return ScriptPromise::reject(scriptState, V8ThrowException::createTypeError(scriptState->isolate(), "The body is opaque."));
- if (bodyUsed())
+ if (isBodyLocked() || bodyUsed())
return ScriptPromise::reject(scriptState, V8ThrowException::createTypeError(scriptState->isolate(), "Already read"));
return ScriptPromise();
}
« no previous file with comments | « third_party/WebKit/Source/modules/fetch/Body.h ('k') | third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698