diff --git a/toolkit/components/url-classifier/content/listmanager.js b/toolkit/components/url-classifier/content/listmanager.js index 018d53f2b82..079178fd88f 100644 --- a/toolkit/components/url-classifier/content/listmanager.js +++ b/toolkit/components/url-classifier/content/listmanager.js @@ -77,7 +77,7 @@ function PROT_ListManager() { this.tablesData = {}; this.observerServiceObserver_ = new G_ObserverServiceObserver( - 'xpcom-shutdown', + 'quit-application', BindToObject(this.shutdown_, this), true /*only once*/); @@ -119,6 +119,10 @@ function PROT_ListManager() { * Delete all of our data tables which seem to leak otherwise. */ PROT_ListManager.prototype.shutdown_ = function() { + if (this.keyManager_) { + this.keyManager_.shutdown(); + } + for (var name in this.tablesData) { delete this.tablesData[name]; } diff --git a/toolkit/components/url-classifier/content/url-crypto-key-manager.js b/toolkit/components/url-classifier/content/url-crypto-key-manager.js index 943319d0da1..5eb837cb2db 100644 --- a/toolkit/components/url-classifier/content/url-crypto-key-manager.js +++ b/toolkit/components/url-classifier/content/url-crypto-key-manager.js @@ -212,8 +212,8 @@ PROT_UrlCryptoKeyManager.prototype.reKey = function() { G_Debug(this, "Attempting to re-key"); // If the keyUrl isn't set, we don't do anything. if (!this.testing_ && this.keyUrl_) { - (new PROT_XMLFetcher()).get(this.keyUrl_, - BindToObject(this.onGetKeyResponse, this)); + this.fetcher_ = new PROT_XMLFetcher(); + this.fetcher_.get(this.keyUrl_, BindToObject(this.onGetKeyResponse, this)); this.updating_ = true; // Calculate the next time we're allowed to re-key. @@ -348,6 +348,7 @@ PROT_UrlCryptoKeyManager.prototype.onGetKeyResponse = function(responseText) { var wrappedKey = response[this.WRAPPED_KEY_NAME]; this.updating_ = false; + this.fetcher_ = null; if (response && clientKey && wrappedKey) { G_Debug(this, "Got new key from: " + responseText); @@ -418,6 +419,13 @@ PROT_UrlCryptoKeyManager.prototype.maybeLoadOldKey = function() { } } +PROT_UrlCryptoKeyManager.prototype.shutdown = function() { + if (this.fetcher_) { + this.fetcher_.cancel(); + this.fetcher_ = null; + } +} + #ifdef DEBUG /** diff --git a/toolkit/components/url-classifier/content/xml-fetcher.js b/toolkit/components/url-classifier/content/xml-fetcher.js index 08d837dcdb6..b79b851af2c 100644 --- a/toolkit/components/url-classifier/content/xml-fetcher.js +++ b/toolkit/components/url-classifier/content/xml-fetcher.js @@ -110,6 +110,11 @@ PROT_XMLFetcher.prototype = { this._request.send(null); }, + cancel: function() { + this._request.onreadystatechange = null; + this._request.abort(); + }, + /** * Called periodically by the request to indicate some state change. 4 * means content has been received.