Bug 520526 - Changes to TimerManager cause test_preventive_maintenance.js to leak due to PlacesDBUtils using TimerManager. r=mak77, r=dtownsend

This commit is contained in:
Robert Strong 2009-10-06 11:12:41 -07:00
parent 3c5ad17de1
commit aa6793b649

View File

@ -192,6 +192,12 @@ function LOG(module, string) {
}
}
function getObserverService()
{
return Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
}
#ifdef MOZ_UPDATER
XPCOMUtils.defineLazyGetter(this, "gApp", function() {
@ -748,12 +754,6 @@ function readStringFromFile(file) {
return text;
}
function getObserverService()
{
return Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
}
function getDefaultPrefBranch()
{
return gPref.QueryInterface(Ci.nsIPrefService).getDefaultBranch(null);
@ -3160,6 +3160,8 @@ UpdatePrompt.prototype = {
* @constructor
*/
function TimerManager() {
let os = getObserverService();
os.addObserver(this, "xpcom-shutdown", false);
}
TimerManager.prototype = {
/**
@ -3192,19 +3194,19 @@ TimerManager.prototype = {
* See nsIObserver.idl
*/
observe: function TM_observe(aSubject, aTopic, aData) {
var os = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
switch (aTopic) {
case "profile-after-change":
os.addObserver(this, "xpcom-shutdown", false);
this._start();
break;
case "xpcom-shutdown":
let os = getObserverService();
os.removeObserver(this, "xpcom-shutdown");
// Release everything we hold onto.
this._timer.cancel();
this._timer = null;
if (this._timer) {
this._timer.cancel();
this._timer = null;
}
for (var timerID in this._timers)
delete this._timers[timerID];
this._timers = null;