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

Unified Diff: third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.h

Issue 2277143002: Use BytesConsumer in BodyStreamBuffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bytes-consumer-tee
Patch Set: rebase Created 4 years, 3 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
Index: third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.h
diff --git a/third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.h b/third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.h
index 707ab666a98dbd0fffe67e4dab25e2f872145044..7521a6d194464e22d1664c19daf110b0ba1bb425 100644
--- a/third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.h
+++ b/third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.h
@@ -10,6 +10,7 @@
#include "core/dom/DOMException.h"
#include "core/streams/UnderlyingSourceBase.h"
#include "modules/ModulesExport.h"
+#include "modules/fetch/BytesConsumer.h"
#include "modules/fetch/FetchDataConsumerHandle.h"
#include "modules/fetch/FetchDataLoader.h"
#include "platform/heap/Handle.h"
@@ -21,15 +22,16 @@ namespace blink {
class EncodedFormData;
class ScriptState;
-class MODULES_EXPORT BodyStreamBuffer final : public UnderlyingSourceBase, public WebDataConsumerHandle::Client {
+class MODULES_EXPORT BodyStreamBuffer final : public UnderlyingSourceBase, public BytesConsumer::Client {
WTF_MAKE_NONCOPYABLE(BodyStreamBuffer);
USING_GARBAGE_COLLECTED_MIXIN(BodyStreamBuffer);
public:
- // Needed because we have to release |m_reader| promptly.
- EAGERLY_FINALIZE();
// |handle| cannot be null and cannot be locked.
// This function must be called with entering an appropriate V8 context.
BodyStreamBuffer(ScriptState*, std::unique_ptr<FetchDataConsumerHandle> /* handle */);
+ // |consumer| must not have a client.
+ // This function must be called with entering an appropriate V8 context.
+ BodyStreamBuffer(ScriptState*, BytesConsumer* /* consumer */);
// |ReadableStreamOperations::isReadableStream(stream)| must hold.
// This function must be called with entering an appropriate V8 context.
BodyStreamBuffer(ScriptState*, ScriptValue stream);
@@ -37,7 +39,7 @@ public:
ScriptValue stream();
// Callable only when neither locked nor disturbed.
- PassRefPtr<BlobDataHandle> drainAsBlobDataHandle(FetchDataConsumerHandle::Reader::BlobSizePolicy);
+ PassRefPtr<BlobDataHandle> drainAsBlobDataHandle(BytesConsumer::BlobSizePolicy);
PassRefPtr<EncodedFormData> drainAsFormData();
void startLoading(FetchDataLoader*, FetchDataLoader::Client* /* client */);
void tee(BodyStreamBuffer**, BodyStreamBuffer**);
@@ -48,8 +50,8 @@ public:
bool hasPendingActivity() const override;
void stop() override;
- // WebDataConsumerHandle::Client
- void didGetReadable() override;
+ // BytesConsumer::Client
+ void onStateChange() override;
bool isStreamReadable();
bool isStreamClosed();
@@ -61,6 +63,7 @@ public:
DEFINE_INLINE_TRACE()
{
+ visitor->trace(m_consumer);
visitor->trace(m_loader);
UnderlyingSourceBase::trace(visitor);
}
@@ -68,16 +71,16 @@ public:
private:
class LoaderClient;
+ BytesConsumer* releaseHandle();
void close();
void error();
+ void cancelConsumer();
void processData();
void endLoading();
void stopLoading();
- std::unique_ptr<FetchDataConsumerHandle> releaseHandle();
RefPtr<ScriptState> m_scriptState;
- std::unique_ptr<FetchDataConsumerHandle> m_handle;
- std::unique_ptr<FetchDataConsumerHandle::Reader> m_reader;
+ Member<BytesConsumer> m_consumer;
// We need this member to keep it alive while loading.
Member<FetchDataLoader> m_loader;
bool m_streamNeedsMore = false;
« no previous file with comments | « third_party/WebKit/Source/modules/fetch/BUILD.gn ('k') | third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698