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

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

Issue 2526293002: [wrapper-tracing] Untangle non-trivial mixin ctors (Closed)
Patch Set: s/new BodyStreamBuffer/BodyStreamBuffer::create/ Created 4 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/BodyStreamBuffer.cpp
diff --git a/third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.cpp b/third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.cpp
index bd4a4dfcfa9dc8c685128bd2574425beb071c3de..33879f9c3461e3a5bff5f2557e00be1713209435 100644
--- a/third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.cpp
+++ b/third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.cpp
@@ -75,45 +75,62 @@ class BodyStreamBuffer::LoaderClient final
Member<FetchDataLoader::Client> m_client;
};
-BodyStreamBuffer::BodyStreamBuffer(ScriptState* scriptState,
- BytesConsumer* consumer)
- : UnderlyingSourceBase(scriptState),
- m_scriptState(scriptState),
- m_consumer(consumer),
- m_madeFromReadableStream(false) {
- v8::Local<v8::Value> bodyValue = toV8(this, scriptState);
haraken 2016/11/24 23:36:32 Why do we need to move the contents of the constru
Michael Lippautz 2016/11/25 07:21:26 Thanks for the clarification, makes sense.
- DCHECK(!bodyValue.IsEmpty());
- DCHECK(bodyValue->IsObject());
- v8::Local<v8::Object> body = bodyValue.As<v8::Object>();
+BodyStreamBuffer* BodyStreamBuffer::create(ScriptState* scriptState,
+ BytesConsumer* consumer) {
+ BodyStreamBuffer* buffer = new BodyStreamBuffer(scriptState, consumer);
ScriptValue readableStream = ReadableStreamOperations::createReadableStream(
- scriptState, this,
+ scriptState, buffer,
ReadableStreamOperations::createCountQueuingStrategy(scriptState, 0));
DCHECK(!readableStream.isEmpty());
+
+ v8::Local<v8::Value> bodyValue = toV8(buffer, scriptState);
+ DCHECK(!bodyValue.IsEmpty());
+ DCHECK(bodyValue->IsObject());
+ v8::Local<v8::Object> body = bodyValue.As<v8::Object>();
V8HiddenValue::setHiddenValue(
scriptState, body,
V8HiddenValue::internalBodyStream(scriptState->isolate()),
readableStream.v8Value());
- m_consumer->setClient(this);
- onStateChange();
+
+ buffer->announceClientToConsumer();
+ return buffer;
}
-BodyStreamBuffer::BodyStreamBuffer(ScriptState* scriptState, ScriptValue stream)
- : UnderlyingSourceBase(scriptState),
- m_scriptState(scriptState),
- m_madeFromReadableStream(true) {
+BodyStreamBuffer* BodyStreamBuffer::create(ScriptState* scriptState,
+ ScriptValue stream) {
DCHECK(ReadableStreamOperations::isReadableStream(scriptState, stream));
- v8::Local<v8::Value> bodyValue = toV8(this, scriptState);
+
+ BodyStreamBuffer* buffer = new BodyStreamBuffer(scriptState, stream);
+
+ v8::Local<v8::Value> bodyValue = toV8(buffer, scriptState);
DCHECK(!bodyValue.IsEmpty());
DCHECK(bodyValue->IsObject());
v8::Local<v8::Object> body = bodyValue.As<v8::Object>();
-
V8HiddenValue::setHiddenValue(
scriptState, body,
V8HiddenValue::internalBodyStream(scriptState->isolate()),
stream.v8Value());
+ return buffer;
}
+void BodyStreamBuffer::announceClientToConsumer() {
+ m_consumer->setClient(this);
+ onStateChange();
+}
+
+BodyStreamBuffer::BodyStreamBuffer(ScriptState* scriptState,
+ BytesConsumer* consumer)
+ : UnderlyingSourceBase(scriptState),
+ m_scriptState(scriptState),
+ m_consumer(consumer),
+ m_madeFromReadableStream(false) {}
+
+BodyStreamBuffer::BodyStreamBuffer(ScriptState* scriptState, ScriptValue stream)
+ : UnderlyingSourceBase(scriptState),
+ m_scriptState(scriptState),
+ m_madeFromReadableStream(true) {}
+
ScriptValue BodyStreamBuffer::stream() {
ScriptState::Scope scope(m_scriptState.get());
v8::Local<v8::Value> bodyValue = toV8(this, m_scriptState.get());
@@ -184,16 +201,16 @@ void BodyStreamBuffer::tee(BodyStreamBuffer** branch1,
ScriptValue stream1, stream2;
ReadableStreamOperations::tee(m_scriptState.get(), stream(), &stream1,
&stream2);
- *branch1 = new BodyStreamBuffer(m_scriptState.get(), stream1);
- *branch2 = new BodyStreamBuffer(m_scriptState.get(), stream2);
+ *branch1 = BodyStreamBuffer::create(m_scriptState.get(), stream1);
+ *branch2 = BodyStreamBuffer::create(m_scriptState.get(), stream2);
return;
}
BytesConsumer* dest1 = nullptr;
BytesConsumer* dest2 = nullptr;
BytesConsumer::tee(m_scriptState->getExecutionContext(), releaseHandle(),
&dest1, &dest2);
- *branch1 = new BodyStreamBuffer(m_scriptState.get(), dest1);
- *branch2 = new BodyStreamBuffer(m_scriptState.get(), dest2);
+ *branch1 = BodyStreamBuffer::create(m_scriptState.get(), dest1);
+ *branch2 = BodyStreamBuffer::create(m_scriptState.get(), dest2);
}
ScriptPromise BodyStreamBuffer::pull(ScriptState* scriptState) {

Powered by Google App Engine
This is Rietveld 408576698