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

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

Issue 1192913007: Change BodyStreamBuffer to be FetchDataConsumerHandle-based and enable backpressure in Fetch API (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase. Created 5 years, 5 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/cachestorage/Cache.cpp ('k') | Source/modules/fetch/Body.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/fetch/Body.h
diff --git a/Source/modules/fetch/Body.h b/Source/modules/fetch/Body.h
index 64ef336982a4de200ca13e61af58509e37109db1..55b334e94d71609cdc0958b001b4271657b821b4 100644
--- a/Source/modules/fetch/Body.h
+++ b/Source/modules/fetch/Body.h
@@ -20,6 +20,7 @@
namespace blink {
class BodyStreamBuffer;
+class DrainingBodyStreamBuffer;
class BodyStreamSource;
class DOMException;
class ReadableByteStream;
@@ -60,63 +61,43 @@ public:
bool bodyUsed() const;
void lockBody(LockBodyOption = LockBodyOptionNone);
- // Returns true if the body stream is (possibly partially) consumed.
- bool isBodyConsumed() const;
- // Sets |m_stream| to a newly created stream from |source|.
- void setBody(ReadableStreamSource* /* source */);
-
- void setBody(PassRefPtr<BlobDataHandle> handle)
- {
- setBody(createBodySource(handle));
- }
- void setBody(BodyStreamBuffer* buffer)
- {
- setBody(createBodySource(buffer));
- }
-
- // Creates a new BodyStreamBuffer to drain the data from the ReadableStream.
- BodyStreamBuffer* createDrainingStream();
+ // Creates a DrainingBodyStreamBuffer to access body data.
+ // Returns nullptr if underlying BodyStreamBuffer is null.
+ PassOwnPtr<DrainingBodyStreamBuffer> createDrainingStream();
// ActiveDOMObject override.
- virtual void stop() override;
virtual bool hasPendingActivity() const override;
- ReadableStreamSource* createBodySource(PassRefPtr<BlobDataHandle>);
- ReadableStreamSource* createBodySource(BodyStreamBuffer*);
-
DECLARE_VIRTUAL_TRACE();
- BodyStreamBuffer* bufferForTest() const { return buffer(); }
+protected:
+ // Sets |m_stream| to a newly created stream from |buffer|.
+ // |buffer| can be null.
+ // This is called when the underlying buffer is set/modified.
+ // TODO(hiroshige): Merge FetchRequest/ResponseData::buffer() and
+ // integrate Body::setBody(), Request/Response::refreshBody(),
+ // FetchRequestData::setBuffer() and
+ // FetchResponseData::replaceBodyStreamBuffer().
+ void setBody(BodyStreamBuffer* /* buffer */);
private:
- class BlobHandleReceiver;
-
void pullSource();
void readAllFromStream();
ScriptPromise readAsync(ScriptState*, ResponseType);
- void readAsyncFromBlob(PassRefPtr<BlobDataHandle>);
- void readAsyncFromFetchDataConsumerHandle(FetchDataConsumerHandle*, const String& mimeType);
+ void resolveWithEmptyDataSynchronously();
+ void readAsyncFromDrainingBodyStreamBuffer(PassOwnPtr<DrainingBodyStreamBuffer>, const String& mimeType);
void resolveJSON(const String&);
+ void didFetchDataLoadFinishedFromDrainingStream();
+
// FetchDataLoader::Client functions.
void didFetchDataLoadFailed() override;
void didFetchDataLoadedBlobHandle(PassRefPtr<BlobDataHandle>) override;
void didFetchDataLoadedArrayBuffer(PassRefPtr<DOMArrayBuffer>) override;
void didFetchDataLoadedString(const String&) override;
- void didBlobHandleReceiveError(DOMException*);
-
- // We use BlobDataHandle or BodyStreamBuffer as data container of the Body.
- // BodyStreamBuffer is used only when the Response object is created by
- // fetch() API.
- // FIXME: We should seek a cleaner way to handle the data.
- virtual PassRefPtr<BlobDataHandle> blobDataHandle() const = 0;
- virtual BodyStreamBuffer* buffer() const = 0;
virtual String mimeType() const = 0;
- void didFinishLoadingViaStream(PassRefPtr<DOMArrayBuffer>);
-
- Member<FetchDataLoader> m_fetchDataLoader;
bool m_bodyUsed;
ResponseType m_responseType;
RefPtrWillBeMember<ScriptPromiseResolver> m_resolver;
« no previous file with comments | « Source/modules/cachestorage/Cache.cpp ('k') | Source/modules/fetch/Body.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698