зеркало из https://github.com/mozilla/pjs.git
Bug 657480: Clean up after TelemetryPing.js r=mak
This commit is contained in:
Родитель
6ec50b919e
Коммит
00b9850cdd
|
@ -235,12 +235,25 @@ TelemetryPing.prototype = {
|
|||
let idleService = Cc["@mozilla.org/widget/idleservice;1"].
|
||||
getService(Ci.nsIIdleService);
|
||||
idleService.addIdleObserver(self, TELEMETRY_INTERVAL);
|
||||
Services.obs.addObserver(self, "idle-daily", null);
|
||||
Services.obs.addObserver(self, "idle-daily", false);
|
||||
Services.obs.addObserver(self, "profile-before-change", false);
|
||||
self.gatherMemory();
|
||||
delete self._timer
|
||||
}
|
||||
this._timer.initWithCallback(timerCallback, TELEMETRY_DELAY, Ci.nsITimer.TYPE_ONE_SHOT);
|
||||
},
|
||||
|
||||
/**
|
||||
* Remove observers to avoid leaks
|
||||
*/
|
||||
uninstall: function uninstall() {
|
||||
let idleService = Cc["@mozilla.org/widget/idleservice;1"].
|
||||
getService(Ci.nsIIdleService);
|
||||
idleService.removeIdleObserver(this, TELEMETRY_INTERVAL);
|
||||
Services.obs.removeObserver(this, "idle-daily");
|
||||
Services.obs.removeObserver(this, "profile-before-change");
|
||||
},
|
||||
|
||||
/**
|
||||
* This observer drives telemetry.
|
||||
*/
|
||||
|
@ -252,6 +265,9 @@ TelemetryPing.prototype = {
|
|||
case "profile-after-change":
|
||||
this.setup();
|
||||
break;
|
||||
case "profile-before-change":
|
||||
this.uninstall();
|
||||
break;
|
||||
case "idle":
|
||||
this.gatherMemory();
|
||||
break;
|
||||
|
|
Загрузка…
Ссылка в новой задаче