80 lines
4.1 KiB
Diff
80 lines
4.1 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Cheng Zhao <zcbenz@gmail.com>
|
|
Date: Thu, 20 Sep 2018 17:47:12 -0700
|
|
Subject: worker_context_will_destroy.patch
|
|
|
|
|
|
diff --git a/content/public/renderer/content_renderer_client.h b/content/public/renderer/content_renderer_client.h
|
|
index 3166cbe259daafc8644b0b1a8941160205638046..b8a81f37db6a979cfbda8743fe4db435ad92dc40 100644
|
|
--- a/content/public/renderer/content_renderer_client.h
|
|
+++ b/content/public/renderer/content_renderer_client.h
|
|
@@ -392,6 +392,11 @@ class CONTENT_EXPORT ContentRendererClient {
|
|
virtual void DidInitializeWorkerContextOnWorkerThread(
|
|
v8::Local<v8::Context> context) {}
|
|
|
|
+ // Notifies that a worker context will be destroyed. This function is called
|
|
+ // from the worker thread.
|
|
+ virtual void WillDestroyWorkerContextOnWorkerThread(
|
|
+ v8::Local<v8::Context> context) {}
|
|
+
|
|
// Overwrites the given URL to use an HTML5 embed if possible.
|
|
// An empty URL is returned if the URL is not overriden.
|
|
virtual GURL OverrideFlashEmbedWithHTML(const GURL& url);
|
|
diff --git a/content/renderer/renderer_blink_platform_impl.cc b/content/renderer/renderer_blink_platform_impl.cc
|
|
index 8eb8b5a763c58da80ab826f629aa33e0d782ad14..09d638e7e74835b032bfbfb15f9ebbf6f7b7cec7 100644
|
|
--- a/content/renderer/renderer_blink_platform_impl.cc
|
|
+++ b/content/renderer/renderer_blink_platform_impl.cc
|
|
@@ -1176,6 +1176,12 @@ void RendererBlinkPlatformImpl::WillStopWorkerThread() {
|
|
WorkerThreadRegistry::Instance()->WillStopCurrentWorkerThread();
|
|
}
|
|
|
|
+void RendererBlinkPlatformImpl::WorkerContextWillDestroy(
|
|
+ const v8::Local<v8::Context>& worker) {
|
|
+ GetContentClient()->renderer()->WillDestroyWorkerContextOnWorkerThread(
|
|
+ worker);
|
|
+}
|
|
+
|
|
void RendererBlinkPlatformImpl::WorkerContextCreated(
|
|
const v8::Local<v8::Context>& worker) {
|
|
GetContentClient()->renderer()->DidInitializeWorkerContextOnWorkerThread(
|
|
diff --git a/content/renderer/renderer_blink_platform_impl.h b/content/renderer/renderer_blink_platform_impl.h
|
|
index 4ec814fd92c5accf70627d37f4966e3e5270b660..aa405311a4588ad4903f637fc07713bd18b34e68 100644
|
|
--- a/content/renderer/renderer_blink_platform_impl.h
|
|
+++ b/content/renderer/renderer_blink_platform_impl.h
|
|
@@ -207,6 +207,7 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl {
|
|
void DidStartWorkerThread() override;
|
|
void WillStopWorkerThread() override;
|
|
void WorkerContextCreated(const v8::Local<v8::Context>& worker) override;
|
|
+ void WorkerContextWillDestroy(const v8::Local<v8::Context>& worker) override;
|
|
|
|
// Disables the WebSandboxSupport implementation for testing.
|
|
// Tests that do not set up a full sandbox environment should call
|
|
diff --git a/third_party/blink/public/platform/platform.h b/third_party/blink/public/platform/platform.h
|
|
index f016cfb6d31d0feeb32800fe6bc1c0421bad66e0..19761866164e9a20221ce552af7683c77a21f551 100644
|
|
--- a/third_party/blink/public/platform/platform.h
|
|
+++ b/third_party/blink/public/platform/platform.h
|
|
@@ -692,6 +692,7 @@ class BLINK_PLATFORM_EXPORT Platform {
|
|
virtual void DidStartWorkerThread() {}
|
|
virtual void WillStopWorkerThread() {}
|
|
virtual void WorkerContextCreated(const v8::Local<v8::Context>& worker) {}
|
|
+ virtual void WorkerContextWillDestroy(const v8::Local<v8::Context>& worker) {}
|
|
virtual bool AllowScriptExtensionForServiceWorker(const WebURL& script_url) {
|
|
return false;
|
|
}
|
|
diff --git a/third_party/blink/renderer/core/workers/worker_thread.cc b/third_party/blink/renderer/core/workers/worker_thread.cc
|
|
index a231d079da2dc70a1054ea6cd4335bad8b2a0253..9343e83988a5bfd7f83ead484be61ac8c17b1196 100644
|
|
--- a/third_party/blink/renderer/core/workers/worker_thread.cc
|
|
+++ b/third_party/blink/renderer/core/workers/worker_thread.cc
|
|
@@ -528,6 +528,12 @@ void WorkerThread::PrepareForShutdownOnWorkerThread() {
|
|
SetExitCode(ExitCode::kGracefullyTerminated);
|
|
}
|
|
|
|
+ {
|
|
+ v8::HandleScope handle_scope(GetIsolate());
|
|
+ Platform::Current()->WorkerContextWillDestroy(
|
|
+ GlobalScope()->ScriptController()->GetContext());
|
|
+ }
|
|
+
|
|
if (WorkerThreadDebugger* debugger = WorkerThreadDebugger::From(GetIsolate()))
|
|
debugger->WorkerThreadDestroyed(this);
|
|
|