Bug 887889 - Clean up ContentPrefServiceChild on xpcom-shutdown r=mak
authorDoug Thayer <dothayer@mozilla.com>
Fri, 30 Mar 2018 15:54:08 -0700
changeset 415938 6480e870dd73969336b30fb2c0ecfc20c91b3d71
parent 415937 7e4a87170569ece8bec68b8163e430ca43937a44
child 415939 fad1b59c9f557e5d6f09c51b578c2ee9762d26c1
push id33911
push usercsabou@mozilla.com
push dateFri, 27 Apr 2018 10:01:39 +0000
treeherdermozilla-central@822936017145 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs887889
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 887889 - Clean up ContentPrefServiceChild on xpcom-shutdown r=mak I'm not sure why this became necessary as a result of migrating to Sqlite.jsm, but this is the only way I've found to eliminate leaks from the tab process on shutdown. These leaks occur when the child process requests something from the ContentPrefService2 but shuts down before it gets its response. MozReview-Commit-ID: 2Haks17D6Em
toolkit/components/contentprefs/ContentPrefServiceChild.jsm
--- a/toolkit/components/contentprefs/ContentPrefServiceChild.jsm
+++ b/toolkit/components/contentprefs/ContentPrefServiceChild.jsm
@@ -57,16 +57,23 @@ var ContentPrefServiceChild = {
 
   // Map from random ID string -> CallbackCaller, per request
   _requests: new Map(),
 
   init() {
     Services.cpmm.addMessageListener("ContentPrefs:HandleResult", this);
     Services.cpmm.addMessageListener("ContentPrefs:HandleError", this);
     Services.cpmm.addMessageListener("ContentPrefs:HandleCompletion", this);
+    Services.obs.addObserver(this, "xpcom-shutdown");
+  },
+
+  observe() {
+    Services.obs.removeObserver(this, "xpcom-shutdown");
+    delete this._observers;
+    delete this._requests;
   },
 
   receiveMessage(msg) {
     let data = msg.data;
     let callback;
     switch (msg.name) {
       case "ContentPrefs:HandleResult":
         callback = this._requests.get(data.requestId);