80 lines
4 KiB
Diff
80 lines
4 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 5bcf6f95f630ae6232ec9be7d8de7360a1592566..3142a8286e6aaf508a06cee0e32c73903682261f 100644
|
|
--- a/content/public/renderer/content_renderer_client.h
|
|
+++ b/content/public/renderer/content_renderer_client.h
|
|
@@ -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
|
|
index 2e3a922dd2a8a15bfe3eec802085f09d3eda9e5d..30da4053a8438dd018fb2739a6cc0e300af2e657 100644
|
|
--- a/content/renderer/renderer_blink_platform_impl.cc
|
|
+++ b/content/renderer/renderer_blink_platform_impl.cc
|
|
@@ -1056,6 +1056,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 f5298e5e942e43008e469214ba252932cc6d771a..ae28b78037e0a078dd9e11fb0cd3edbfdd0ff986 100644
|
|
--- a/content/renderer/renderer_blink_platform_impl.h
|
|
+++ b/content/renderer/renderer_blink_platform_impl.h
|
|
@@ -201,6 +201,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;
|
|
|
|
void RecordMetricsForBackgroundedRendererPurge() override;
|
|
|
|
diff --git a/third_party/blink/public/platform/platform.h b/third_party/blink/public/platform/platform.h
|
|
index 921175528990fffc8fda609e768be47b856f7621..f52b4d1573c07a9c280d67bc3b2389dd3a549925 100644
|
|
--- a/third_party/blink/public/platform/platform.h
|
|
+++ b/third_party/blink/public/platform/platform.h
|
|
@@ -660,6 +660,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 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
|
|
index 0da8aa29d7ddf6564d46fd1b439f040bc9491527..4c9163415298c2e766e0d64f8a2b0d9110a9032c 100644
|
|
--- a/third_party/blink/renderer/core/workers/worker_thread.cc
|
|
+++ b/third_party/blink/renderer/core/workers/worker_thread.cc
|
|
@@ -634,6 +634,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);
|
|
|