Bug 584402 - Audit references across XPCOM borders [r=mconnor]

Use weak references for observers.
This commit is contained in:
Philipp von Weitershausen 2010-08-04 21:07:53 +02:00
parent bf06e6e72e
commit e97c6b419f
3 changed files with 7 additions and 5 deletions

View File

@ -1001,7 +1001,7 @@ function BookmarksTracker(name) {
for (let guid in kSpecialIds)
this.ignoreID(guid);
Svc.Bookmark.addObserver(this, false);
Svc.Bookmark.addObserver(this, true);
// Explicitly nullify our references to our cached services so we don't leak
Observers.add("places-shutdown", function() {
@ -1030,7 +1030,8 @@ BookmarksTracker.prototype = {
QueryInterface: XPCOMUtils.generateQI([
Ci.nsINavBookmarkObserver,
Ci.nsINavBookmarkObserver_MOZILLA_1_9_1_ADDITIONS
Ci.nsINavBookmarkObserver_MOZILLA_1_9_1_ADDITIONS,
Ci.nsISupportsWeakReference
]),
/**

View File

@ -257,14 +257,15 @@ HistoryStore.prototype = {
function HistoryTracker(name) {
Tracker.call(this, name);
Svc.History.addObserver(this, false);
Svc.History.addObserver(this, true);
}
HistoryTracker.prototype = {
__proto__: Tracker.prototype,
QueryInterface: XPCOMUtils.generateQI([
Ci.nsINavHistoryObserver,
Ci.nsINavHistoryObserver_MOZILLA_1_9_1_ADDITIONS
Ci.nsINavHistoryObserver_MOZILLA_1_9_1_ADDITIONS,
Ci.nsISupportsWeakReference
]),
onBeginUpdateBatch: function HT_onBeginUpdateBatch() {},

View File

@ -232,7 +232,7 @@ function TabTracker(name) {
this.onTab = Utils.bind2(this, this.onTab);
// Register as an observer so we can catch windows opening and closing:
Svc.WinWatcher.registerNotification(this);
Svc.Obs.add("domwindowopened", this);
// Also register listeners on already open windows
let wins = Svc.WinMediator.getEnumerator("navigator:browser");