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

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

Issue 2006803006: [Fetch API] Do not call v8 Extra script when the worker is terminating (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 639665ede11d54291dd5e5b3380d8677997c8a63..40be088a6058fef84d68695673a0d922b9644df9 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,12 @@ public:
bool done;
v8::Local<v8::Value> item = v.v8Value();
ASSERT(item->IsObject());
- v8::Local<v8::Value> value = v8CallOrCrash(v8UnpackIteratorResult(v.getScriptState(), item.As<v8::Object>(), &done));
+ 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 = v8CallOrCrash(maybeValue);
if (done) {
readingContext->onReadDone();
return v;
« 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