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

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

Issue 2277703002: Revert of Streams: Remove isTerminating() calls (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 | « third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/fetch/ReadableStreamDataConsumerHandle.cpp
diff --git a/third_party/WebKit/Source/modules/fetch/ReadableStreamDataConsumerHandle.cpp b/third_party/WebKit/Source/modules/fetch/ReadableStreamDataConsumerHandle.cpp
index 9f4533ad514c5ac482bb27c05f6c8d198f62af4e..ca69f165054155930f38448de3f1a78276f13cf0 100644
--- a/third_party/WebKit/Source/modules/fetch/ReadableStreamDataConsumerHandle.cpp
+++ b/third_party/WebKit/Source/modules/fetch/ReadableStreamDataConsumerHandle.cpp
@@ -12,8 +12,10 @@
#include "bindings/core/v8/V8BindingMacros.h"
#include "bindings/core/v8/V8IteratorResultValue.h"
#include "bindings/core/v8/V8Uint8Array.h"
+#include "bindings/core/v8/WorkerOrWorkletScriptController.h"
#include "core/dom/DOMTypedArray.h"
#include "core/streams/ReadableStreamOperations.h"
+#include "core/workers/WorkerGlobalScope.h"
#include "public/platform/Platform.h"
#include "public/platform/WebTaskRunner.h"
#include "public/platform/WebThread.h"
@@ -27,6 +29,20 @@
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
+
using Result = WebDataConsumerHandle::Result;
using Flags = WebDataConsumerHandle::Flags;
@@ -49,7 +65,11 @@
bool done;
v8::Local<v8::Value> item = v.v8Value();
ASSERT(item->IsObject());
+ if (isTerminating(v.getScriptState()))
+ return ScriptValue();
v8::MaybeLocal<v8::Value> maybeValue = v8UnpackIteratorResult(v.getScriptState(), item.As<v8::Object>(), &done);
+ if (isTerminating(v.getScriptState()))
+ return ScriptValue();
v8::Local<v8::Value> value = maybeValue.ToLocalChecked();
if (done) {
readingContext->onReadDone();
« no previous file with comments | « third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698