electron/patches/common/chromium/worker_context_will_destroy.patch

81 lines
4 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
2019-05-13 18:49:01 +00:00
index 9e405a1f92c8218387ca270c8d2ccdb7030d3ad6..bb625490e2dd86c72e903a5d713881fdf8185cff 100644
--- a/content/public/renderer/content_renderer_client.h
+++ b/content/public/renderer/content_renderer_client.h
2019-05-13 18:49:01 +00:00
@@ -384,6 +384,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
2019-05-13 18:49:01 +00:00
index 01b7e68dba2ccfedf0491cd0387e3e0729473c2a..1364adb8e06da07812137ff19e550b4ff3a345e9 100644
--- a/content/renderer/renderer_blink_platform_impl.cc
+++ b/content/renderer/renderer_blink_platform_impl.cc
2019-05-13 18:49:01 +00:00
@@ -1072,6 +1072,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
2019-05-13 18:49:01 +00:00
index 91345bba1ecd1a28e2588fa2f93b6226b3904467..5fb3283310675d15a5ed387fb33b1bc01b8ceff0 100644
--- a/content/renderer/renderer_blink_platform_impl.h
+++ b/content/renderer/renderer_blink_platform_impl.h
2019-05-13 18:49:01 +00:00
@@ -205,6 +205,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;
2019-03-21 22:45:52 +00:00
void RecordMetricsForBackgroundedRendererPurge() override;
diff --git a/third_party/blink/public/platform/platform.h b/third_party/blink/public/platform/platform.h
2019-05-13 18:49:01 +00:00
index cf06aa2c9beda4a2b6c7f484da971b1b5de2b79b..13b1bbe8098fdbe9096fc61e99d88b038a57df54 100644
--- a/third_party/blink/public/platform/platform.h
+++ b/third_party/blink/public/platform/platform.h
2019-05-13 18:49:01 +00:00
@@ -664,6 +664,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) {}
2019-02-14 16:34:15 +00:00
virtual bool AllowScriptExtensionForServiceWorker(
const WebSecurityOrigin& script_origin) {
return false;
diff --git a/third_party/blink/renderer/core/workers/worker_thread.cc b/third_party/blink/renderer/core/workers/worker_thread.cc
2019-05-13 18:49:01 +00:00
index 4b2aacabf151c7aacf3a338cc47f1faf0c7b9391..308c10136d7ccf735b216ac5be4af846b218841a 100644
--- a/third_party/blink/renderer/core/workers/worker_thread.cc
+++ b/third_party/blink/renderer/core/workers/worker_thread.cc
2019-05-13 18:49:01 +00:00
@@ -640,6 +640,12 @@ void WorkerThread::PrepareForShutdownOnWorkerThread() {
nested_runner_->QuitNow();
}
+ {
+ v8::HandleScope handle_scope(GetIsolate());
+ Platform::Current()->WorkerContextWillDestroy(
+ GlobalScope()->ScriptController()->GetContext());
+ }
+
if (WorkerThreadDebugger* debugger = WorkerThreadDebugger::From(GetIsolate()))
debugger->WorkerThreadDestroyed(this);
2018-09-21 00:30:26 +00:00