2018-10-24 18:24:11 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
|
2018-09-14 05:02:16 +00:00
|
|
|
diff --git a/content/public/renderer/content_renderer_client.h b/content/public/renderer/content_renderer_client.h
|
2019-06-04 03:44:12 +00:00
|
|
|
index 31fcd7d89bf8f23d32ad385351d272e81aad36a1..373a76a576e2ccdf604036daadf012c24d409858 100644
|
2018-09-14 05:02:16 +00:00
|
|
|
--- a/content/public/renderer/content_renderer_client.h
|
|
|
|
+++ b/content/public/renderer/content_renderer_client.h
|
2019-06-04 03:44:12 +00:00
|
|
|
@@ -389,6 +389,11 @@ class CONTENT_EXPORT ContentRendererClient {
|
2018-09-14 05:02:16 +00:00
|
|
|
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-06-04 03:44:12 +00:00
|
|
|
index 8bdf34b7a2fae5941f986434d2ff39d1f6ab332a..c89bcd9d4ed37c68ec19f0d4976fe64f7ebdbb2b 100644
|
2018-09-14 05:02:16 +00:00
|
|
|
--- a/content/renderer/renderer_blink_platform_impl.cc
|
|
|
|
+++ b/content/renderer/renderer_blink_platform_impl.cc
|
2019-06-04 03:44:12 +00:00
|
|
|
@@ -953,6 +953,12 @@ void RendererBlinkPlatformImpl::WillStopWorkerThread() {
|
2018-09-14 05:02:16 +00:00
|
|
|
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-06-04 03:44:12 +00:00
|
|
|
index a7cc63d04922b00cd2c65283343a9315e86a6bae..5f315876dce8fc0b695c0aa44da9cc54d9ec0fe1 100644
|
2018-09-14 05:02:16 +00:00
|
|
|
--- a/content/renderer/renderer_blink_platform_impl.h
|
|
|
|
+++ b/content/renderer/renderer_blink_platform_impl.h
|
2019-06-04 03:44:12 +00:00
|
|
|
@@ -188,6 +188,7 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl {
|
2018-09-14 05:02:16 +00:00
|
|
|
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-06-04 03:44:12 +00:00
|
|
|
bool IsExcludedHeaderForServiceWorkerFetchEvent(
|
|
|
|
const blink::WebString& header_name) override;
|
2019-03-21 22:45:52 +00:00
|
|
|
|
2018-09-14 18:03:43 +00:00
|
|
|
diff --git a/third_party/blink/public/platform/platform.h b/third_party/blink/public/platform/platform.h
|
2019-06-04 03:44:12 +00:00
|
|
|
index 19b78466e66fcaf9a1cc44346e2e47f79381bf36..c2c24e3950d647ecd14585e0ed0277c1f8774290 100644
|
2018-09-14 18:03:43 +00:00
|
|
|
--- a/third_party/blink/public/platform/platform.h
|
|
|
|
+++ b/third_party/blink/public/platform/platform.h
|
2019-06-04 03:44:12 +00:00
|
|
|
@@ -640,6 +640,7 @@ class BLINK_PLATFORM_EXPORT Platform {
|
2018-09-14 18:03:43 +00:00
|
|
|
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) {
|
2018-09-14 18:03:43 +00:00
|
|
|
return false;
|
2018-09-14 05:02:16 +00:00
|
|
|
diff --git a/third_party/blink/renderer/core/workers/worker_thread.cc b/third_party/blink/renderer/core/workers/worker_thread.cc
|
2019-06-04 03:44:12 +00:00
|
|
|
index 6c71516b1906fa2cae5440782595af7a2eea8ab7..c150855e51c6623c950c3875a447217ca091ea50 100644
|
2018-09-14 05:02:16 +00:00
|
|
|
--- a/third_party/blink/renderer/core/workers/worker_thread.cc
|
|
|
|
+++ b/third_party/blink/renderer/core/workers/worker_thread.cc
|
2019-06-04 03:44:12 +00:00
|
|
|
@@ -640,6 +640,12 @@ void WorkerThread::PrepareForShutdownOnWorkerThread() {
|
2019-05-13 18:49:01 +00:00
|
|
|
nested_runner_->QuitNow();
|
2018-09-14 05:02:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
+ {
|
|
|
|
+ v8::HandleScope handle_scope(GetIsolate());
|
|
|
|
+ Platform::Current()->WorkerContextWillDestroy(
|
|
|
|
+ GlobalScope()->ScriptController()->GetContext());
|
|
|
|
+ }
|
|
|
|
+
|
2019-01-12 01:00:43 +00:00
|
|
|
if (WorkerThreadDebugger* debugger = WorkerThreadDebugger::From(GetIsolate()))
|
|
|
|
debugger->WorkerThreadDestroyed(this);
|
2018-09-21 00:30:26 +00:00
|
|
|
|