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

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

Issue 2312413003: Remove isTerminating checks from fetch API + streams code (Closed)
Patch Set: 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.cpp
diff --git a/third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.cpp b/third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.cpp
index 11b50f742a10d067ed13b596b2655d051a6fef77..711489b75225cdbaba3d3764c971ca4bc41a9c7b 100644
--- a/third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.cpp
+++ b/third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.cpp
@@ -6,13 +6,11 @@
#include "bindings/core/v8/ScriptState.h"
#include "bindings/core/v8/V8HiddenValue.h"
-#include "bindings/core/v8/WorkerOrWorkletScriptController.h"
#include "core/dom/DOMArrayBuffer.h"
#include "core/dom/DOMTypedArray.h"
#include "core/dom/ExceptionCode.h"
#include "core/streams/ReadableStreamController.h"
#include "core/streams/ReadableStreamOperations.h"
-#include "core/workers/WorkerGlobalScope.h"
#include "modules/fetch/Body.h"
#include "modules/fetch/BytesConsumerForDataConsumerHandle.h"
#include "modules/fetch/DataConsumerHandleUtil.h"
@@ -24,20 +22,6 @@
namespace blink {
-namespace {
-
-bool isTerminating(ScriptState* scriptState)
-{
- ExecutionContext* executionContext = scriptState->getExecutionContext();
- if (!executionContext)
- return true;
- if (!executionContext->isWorkerGlobalScope())
- return false;
- return toWorkerGlobalScope(executionContext)->scriptController()->isExecutionTerminating();
-}
-
-} // namespace
-
class BodyStreamBuffer::LoaderClient final : public GarbageCollectedFinalized<LoaderClient>, public ActiveDOMObject, public FetchDataLoader::Client {
WTF_MAKE_NONCOPYABLE(LoaderClient);
USING_GARBAGE_COLLECTED_MIXIN(LoaderClient);
@@ -105,28 +89,14 @@ BodyStreamBuffer::BodyStreamBuffer(ScriptState* scriptState, std::unique_ptr<Fet
, m_reader(m_handle->obtainFetchDataReader(this))
, m_madeFromReadableStream(false)
{
- if (isTerminating(scriptState)) {
- m_reader = nullptr;
- m_handle = nullptr;
- return;
- }
v8::Local<v8::Value> bodyValue = toV8(this, scriptState);
- if (bodyValue.IsEmpty()) {
- DCHECK(isTerminating(scriptState));
- m_reader = nullptr;
- m_handle = nullptr;
- return;
- }
+ DCHECK(!bodyValue.IsEmpty());
DCHECK(bodyValue->IsObject());
v8::Local<v8::Object> body = bodyValue.As<v8::Object>();
ScriptValue readableStream = ReadableStreamOperations::createReadableStream(
scriptState, this, ReadableStreamOperations::createCountQueuingStrategy(scriptState, 0));
- if (isTerminating(scriptState)) {
- m_reader = nullptr;
- m_handle = nullptr;
- return;
- }
+ DCHECK(!readableStream.isEmpty());
V8HiddenValue::setHiddenValue(scriptState, body, V8HiddenValue::internalBodyStream(scriptState->isolate()), readableStream.v8Value());
}
@@ -136,13 +106,8 @@ BodyStreamBuffer::BodyStreamBuffer(ScriptState* scriptState, ScriptValue stream)
, m_madeFromReadableStream(true)
{
DCHECK(ReadableStreamOperations::isReadableStream(scriptState, stream));
- if (isTerminating(scriptState))
- return;
v8::Local<v8::Value> bodyValue = toV8(this, scriptState);
- if (bodyValue.IsEmpty()) {
- DCHECK(isTerminating(scriptState));
- return;
- }
+ DCHECK(!bodyValue.IsEmpty());
DCHECK(bodyValue->IsObject());
v8::Local<v8::Object> body = bodyValue.As<v8::Object>();
@@ -152,13 +117,8 @@ BodyStreamBuffer::BodyStreamBuffer(ScriptState* scriptState, ScriptValue stream)
ScriptValue BodyStreamBuffer::stream()
{
ScriptState::Scope scope(m_scriptState.get());
- if (isTerminating(m_scriptState.get()))
- return ScriptValue();
v8::Local<v8::Value> bodyValue = toV8(this, m_scriptState.get());
- if (bodyValue.IsEmpty()) {
- DCHECK(isTerminating(m_scriptState.get()));
- return ScriptValue();
- }
+ DCHECK(!bodyValue.IsEmpty());
DCHECK(bodyValue->IsObject());
v8::Local<v8::Object> body = bodyValue.As<v8::Object>();
return ScriptValue(m_scriptState.get(), V8HiddenValue::getHiddenValue(m_scriptState.get(), body, V8HiddenValue::internalBodyStream(m_scriptState->isolate())));

Powered by Google App Engine
This is Rietveld 408576698