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

Unified Diff: chrome/renderer/resources/extensions/messaging.js

Issue 83023014: Fix chrome.runtime.sendMessage background page memory leak. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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: chrome/renderer/resources/extensions/messaging.js
diff --git a/chrome/renderer/resources/extensions/messaging.js b/chrome/renderer/resources/extensions/messaging.js
index a9a39512e99b61c43e48d8513e32a085503aa5f8..a39ecb1cb6c6b7f7c13ac907fc58397cfc3fd445 100644
--- a/chrome/renderer/resources/extensions/messaging.js
+++ b/chrome/renderer/resources/extensions/messaging.js
@@ -161,7 +161,8 @@
if (!requestEvent.hasListeners())
return false;
var port = createPort(portId, channelName);
- port.onMessage.addListener(function(request) {
+
+ function messageListener(request) {
var responseCallbackPreserved = false;
var responseCallback = function(response) {
if (port) {
@@ -198,7 +199,13 @@
port = null;
}
}
- });
+ }
+
+ port.onDestroy_ = function() {
+ port.onMessage.removeListener(messageListener);
+ };
+ port.onMessage.addListener(messageListener);
+
var eventName = (isSendMessage ?
(isExternal ?
"runtime.onMessageExternal" : "runtime.onMessage") :
« 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