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

Unified Diff: chrome/renderer/resources/renderer_extension_bindings.js

Issue 125280: Send port-closed notification when a frame with ports unloads.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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 | « chrome/renderer/resources/json_schema.js ('k') | webkit/glue/webframe.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/resources/renderer_extension_bindings.js
===================================================================
--- chrome/renderer/resources/renderer_extension_bindings.js (revision 18701)
+++ chrome/renderer/resources/renderer_extension_bindings.js (working copy)
@@ -10,6 +10,7 @@
var chrome = chrome || {};
(function () {
native function OpenChannelToExtension(id);
+ native function CloseChannel(portId);
native function PostMessage(portId, msg);
// Port object. Represents a connection to another script context through
@@ -66,6 +67,12 @@
PostMessage(this.portId_, JSON.stringify(msg));
};
+ // Disconnects the port from the other end.
+ chrome.Port.prototype.disconnect = function() {
+ delete chrome.Port.ports_[this.portId_];
+ CloseChannel(this.portId_);
+ }
+
// Extension object.
chrome.Extension = function(id) {
this.id_ = id;
@@ -85,4 +92,10 @@
chrome.Extension.prototype.getURL = function(path) {
return "chrome-extension://" + this.id_ + "/" + path;
};
+
+ chrome.onUnload_.addListener(function() {
+ for (var i in chrome.Port.ports_) {
+ chrome.Port.ports_[i].disconnect();
+ }
+ });
})();
« no previous file with comments | « chrome/renderer/resources/json_schema.js ('k') | webkit/glue/webframe.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698