mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 17:23:59 +00:00
Bug 985042 - DataStore.jsm removes its inner-window-destroyed observer. r=ehsan
This commit is contained in:
parent
b6ea0644a4
commit
caeca6d43d
@ -68,7 +68,8 @@ this.DataStore.prototype = {
|
||||
classDescription: "DataStore XPCOM Component",
|
||||
classID: Components.ID("{db5c9602-030f-4bff-a3de-881a8de370f2}"),
|
||||
contractID: "@mozilla.org/dom/datastore;1",
|
||||
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsISupports]),
|
||||
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsISupports,
|
||||
Components.interfaces.nsIObserver]),
|
||||
|
||||
callbacks: [],
|
||||
|
||||
@ -92,16 +93,7 @@ this.DataStore.prototype = {
|
||||
this._db = new DataStoreDB();
|
||||
this._db.init(aOwner, aName);
|
||||
|
||||
let self = this;
|
||||
Services.obs.addObserver(function(aSubject, aTopic, aData) {
|
||||
let wId = aSubject.QueryInterface(Ci.nsISupportsPRUint64).data;
|
||||
if (wId == self._innerWindowID) {
|
||||
cpmm.removeMessageListener("DataStore:Changed:Return:OK", self);
|
||||
cpmm.sendAsyncMessage("DataStore:UnregisterForMessages");
|
||||
self._shuttingdown = true;
|
||||
self._db.close();
|
||||
}
|
||||
}, "inner-window-destroyed", false);
|
||||
Services.obs.addObserver(this, "inner-window-destroyed", false);
|
||||
|
||||
let util = aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDOMWindowUtils);
|
||||
@ -112,6 +104,18 @@ this.DataStore.prototype = {
|
||||
{ store: this._name, owner: this._owner });
|
||||
},
|
||||
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
let wId = aSubject.QueryInterface(Ci.nsISupportsPRUint64).data;
|
||||
if (wId == this._innerWindowID) {
|
||||
Services.obs.removeObserver(this, "inner-window-destroyed");
|
||||
|
||||
cpmm.removeMessageListener("DataStore:Changed:Return:OK", this);
|
||||
cpmm.sendAsyncMessage("DataStore:UnregisterForMessages");
|
||||
this._shuttingdown = true;
|
||||
this._db.close();
|
||||
}
|
||||
},
|
||||
|
||||
newDBPromise: function(aTxnType, aFunction) {
|
||||
let self = this;
|
||||
return new this._window.Promise(function(aResolve, aReject) {
|
||||
|
Loading…
Reference in New Issue
Block a user