electron/patches/common/chromium/worker_context_will_destroy.patch

81 lines
4.1 KiB
Diff
Raw Normal View History

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2018-09-21 00:30:26 +00:00
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
2018-10-24 23:25:48 +00:00
index f1c9cc5997cb5e285bd552d58434de7a4b1d2467..86f2215b9d78374569572c6d087a2102506d3dcb 100644
--- a/content/public/renderer/content_renderer_client.h
+++ b/content/public/renderer/content_renderer_client.h
2018-10-24 23:25:48 +00:00
@@ -383,6 +383,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
2018-10-24 23:25:48 +00:00
index a91f06ffb8782630714a88d1d3d00eca0c2c0f7f..291081cf0d428cbef12f99e9296e4b52ce89eca4 100644
--- a/content/renderer/renderer_blink_platform_impl.cc
+++ b/content/renderer/renderer_blink_platform_impl.cc
2018-10-24 23:25:48 +00:00
@@ -1187,6 +1187,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
2018-10-24 23:25:48 +00:00
index b3bde113adbd7a7586981c42c28da5a939ed688f..892f1e653a656ebdab3fda066af0814c991842c3 100644
--- a/content/renderer/renderer_blink_platform_impl.h
+++ b/content/renderer/renderer_blink_platform_impl.h
2018-10-24 23:25:48 +00:00
@@ -208,6 +208,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;
2018-09-21 00:30:26 +00:00
// 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
2018-10-24 23:25:48 +00:00
index 362a2978452e758c8f74739bb5c635e8be9b834f..9730bc3d13721a12ee490d38213c753b130b6d07 100644
--- a/third_party/blink/public/platform/platform.h
+++ b/third_party/blink/public/platform/platform.h
2018-10-24 23:25:48 +00:00
@@ -673,6 +673,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
2018-10-24 23:25:48 +00:00
index 0e1ce1e2ffc9283fa2d23bb7d74b96fbfbf7bf2e..e6789645fb05645d0328685f1e544f0f981d747c 100644
--- a/third_party/blink/renderer/core/workers/worker_thread.cc
+++ b/third_party/blink/renderer/core/workers/worker_thread.cc
2018-10-24 23:25:48 +00:00
@@ -529,6 +529,12 @@ void WorkerThread::PrepareForShutdownOnWorkerThread() {
SetExitCode(ExitCode::kGracefullyTerminated);
}
+ {
+ v8::HandleScope handle_scope(GetIsolate());
+ Platform::Current()->WorkerContextWillDestroy(
+ GlobalScope()->ScriptController()->GetContext());
+ }
+
GetWorkerReportingProxy().WillDestroyWorkerGlobalScope();
2018-09-21 00:30:26 +00:00
probe::AllAsyncTasksCanceled(GlobalScope());