Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Unified Diff: third_party/WebKit/Source/devtools/front_end/common/Worker.js

Issue 2239753003: DevTools: Make sure worker instance is not collected. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressing comment. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/devtools/front_end/common/Worker.js
diff --git a/third_party/WebKit/Source/devtools/front_end/common/Worker.js b/third_party/WebKit/Source/devtools/front_end/common/Worker.js
index bf3ceebce2ba82428d49878bb8a0395532026bbb..5dd60874cd0ef78b351db42601be2025a5488a9b 100644
--- a/third_party/WebKit/Source/devtools/front_end/common/Worker.js
+++ b/third_party/WebKit/Source/devtools/front_end/common/Worker.js
@@ -49,14 +49,18 @@ WebInspector.Worker = function(appName, workerName)
var isSharedWorker = !!workerName;
if (isSharedWorker) {
worker = new SharedWorker(url, workerName);
- worker.port.onmessage = onMessage;
+ worker.port.onmessage = onMessage.bind(this);
} else {
worker = new Worker(url);
- worker.onmessage = onMessage;
+ worker.onmessage = onMessage.bind(this);
}
+ // Hold a reference to worker until the promise is resolved.
+ // Otherwise the worker could be GCed.
+ this._workerProtect = worker;
/**
* @param {!Event} event
+ * @this {WebInspector.Worker}
*/
function onMessage(event)
{
@@ -66,6 +70,7 @@ WebInspector.Worker = function(appName, workerName)
else
worker.onmessage = null;
callback(worker);
+ this._workerProtect = null;
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698