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

Unified Diff: Source/modules/serviceworkers/Body.cpp

Issue 535193002: [ServiceWorker] Add NULL check of ExecutionContext in FetchBodyStream::readAsync (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: incorporated haraken's comment Created 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/serviceworkers/Body.cpp
diff --git a/Source/modules/serviceworkers/Body.cpp b/Source/modules/serviceworkers/Body.cpp
index cd4088d1de1a9be07a2afe53363835d8d833a604..62d6030c57a1a4a328700968e4cd9b82f3fe1d79 100644
--- a/Source/modules/serviceworkers/Body.cpp
+++ b/Source/modules/serviceworkers/Body.cpp
@@ -19,6 +19,16 @@ ScriptPromise Body::readAsync(ScriptState* scriptState, ResponseType type)
if (m_bodyUsed)
return ScriptPromise::reject(scriptState, V8ThrowException::createTypeError("Already read", scriptState->isolate()));
+ // When the main thread sends a V8::TerminateExecution() signal to a worker
+ // thread, any V8 API on the worker thread starts returning an empty
+ // handle. This can happen in Body::readAsync. To avoid the situation, we
+ // first check the ExecutionContext and return immediately if it's already
+ // gone (which means that the V8::TerminateExecution() signal has been sent
+ // to this worker thread).
+ ExecutionContext* executionContext = scriptState->executionContext();
+ if (!executionContext)
+ return ScriptPromise();
+
m_bodyUsed = true;
m_responseType = type;
@@ -62,7 +72,7 @@ ScriptPromise Body::readAsync(ScriptState* scriptState, ResponseType type)
}
m_loader = adoptPtr(new FileReaderLoader(readType, this));
- m_loader->start(scriptState->executionContext(), blobHandle);
+ m_loader->start(executionContext, blobHandle);
return promise;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698