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

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

Issue 1053503002: [Fetch] Response.clone should tee the body stream. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 9 months 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
« no previous file with comments | « Source/modules/fetch/Body.h ('k') | Source/modules/fetch/Request.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/fetch/Body.cpp
diff --git a/Source/modules/fetch/Body.cpp b/Source/modules/fetch/Body.cpp
index bc3bd6d569bdc31bbb4610ab321becc297f8fe71..f80644561fcbefd072de728387f62a7356355637 100644
--- a/Source/modules/fetch/Body.cpp
+++ b/Source/modules/fetch/Body.cpp
@@ -273,7 +273,7 @@ ScriptPromise Body::readAsync(ScriptState* scriptState, ResponseType type)
if (!executionContext)
return ScriptPromise();
- setBodyUsed();
+ lockBody(PassBody);
m_responseType = type;
ASSERT(!m_resolver);
@@ -373,14 +373,15 @@ bool Body::bodyUsed() const
return m_bodyUsed || m_stream->isLocked();
}
-void Body::setBodyUsed()
+void Body::lockBody(LockBodyOption option)
{
- ASSERT(!m_bodyUsed);
+ ASSERT(!bodyUsed());
+ if (option == PassBody)
+ m_bodyUsed = true;
ASSERT(!m_stream->isLocked());
TrackExceptionState exceptionState;
- m_streamReader = m_stream->getBytesReader(executionContext(), exceptionState);
+ m_stream->getBytesReader(executionContext(), exceptionState);
ASSERT(!exceptionState.hadException());
- m_bodyUsed = true;
}
bool Body::streamAccessed() const
@@ -388,6 +389,13 @@ bool Body::streamAccessed() const
return m_streamSource->state() != m_streamSource->Initial;
}
+void Body::refreshBody()
+{
+ m_streamSource = new ReadableStreamSource(this);
+ m_stream = new ReadableByteStream(m_streamSource, new ReadableByteStream::StrictStrategy);
+ m_streamSource->startStream(m_stream);
+}
+
BodyStreamBuffer* Body::createDrainingStream()
{
return m_streamSource->createDrainingStream();
@@ -416,7 +424,6 @@ DEFINE_TRACE(Body)
visitor->trace(m_resolver);
visitor->trace(m_stream);
visitor->trace(m_streamSource);
- visitor->trace(m_streamReader);
ActiveDOMObject::trace(visitor);
}
« no previous file with comments | « Source/modules/fetch/Body.h ('k') | Source/modules/fetch/Request.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698