Bug 1165787 - Use origin in RequestSyncService.jsm. r=ehsan

This commit is contained in:
Yoshi Huang 2015-05-29 19:35:10 +08:00
parent 18dd152e2e
commit 3d7ae75dce

View File

@ -81,7 +81,7 @@ this.RequestSyncService = {
}).bind(this)); }).bind(this));
Services.obs.addObserver(this, 'xpcom-shutdown', false); Services.obs.addObserver(this, 'xpcom-shutdown', false);
Services.obs.addObserver(this, 'webapps-clear-data', false); Services.obs.addObserver(this, 'clear-cookiejar-data', false);
Services.obs.addObserver(this, 'wifi-state-changed', false); Services.obs.addObserver(this, 'wifi-state-changed', false);
this.initDBHelper("requestSync", RSYNCDB_VERSION, [RSYNCDB_NAME]); this.initDBHelper("requestSync", RSYNCDB_VERSION, [RSYNCDB_NAME]);
@ -117,7 +117,7 @@ this.RequestSyncService = {
}).bind(this)); }).bind(this));
Services.obs.removeObserver(this, 'xpcom-shutdown'); Services.obs.removeObserver(this, 'xpcom-shutdown');
Services.obs.removeObserver(this, 'webapps-clear-data'); Services.obs.removeObserver(this, 'clear-cookiejar-data');
Services.obs.removeObserver(this, 'wifi-state-changed'); Services.obs.removeObserver(this, 'wifi-state-changed');
this.close(); this.close();
@ -138,8 +138,8 @@ this.RequestSyncService = {
this.shutdown(); this.shutdown();
break; break;
case 'webapps-clear-data': case 'clear-cookiejar-data':
this.clearData(aSubject); this.clearData(aData);
break; break;
case 'wifi-state-changed': case 'wifi-state-changed':
@ -160,15 +160,7 @@ this.RequestSyncService = {
return; return;
} }
let params = let partialKey = aData;
aData.QueryInterface(Ci.mozIApplicationClearPrivateDataParams);
if (!params) {
return;
}
// At this point we don't have the origin, so we cannot create the full
// key. Using the partial one is enough to detect the uninstalled app.
let partialKey = params.appId + '|' + params.browserOnly + '|';
let dbKeys = []; let dbKeys = [];
for (let key in this._registrations) { for (let key in this._registrations) {
@ -207,9 +199,7 @@ this.RequestSyncService = {
// This method generates the key for the indexedDB object storage. // This method generates the key for the indexedDB object storage.
principalToKey: function(aPrincipal) { principalToKey: function(aPrincipal) {
return aPrincipal.appId + '|' + return aPrincipal.cookieJar + '|' + aPrincipal.origin;
aPrincipal.isInBrowserElement + '|' +
aPrincipal.originNoSuffix;
}, },
// Add a task to the _registrations map and create the timer if it's needed. // Add a task to the _registrations map and create the timer if it's needed.
@ -382,10 +372,7 @@ this.RequestSyncService = {
aData.params.overwrittenMinInterval = 0; aData.params.overwrittenMinInterval = 0;
let dbKey = aData.task + "|" + let dbKey = aData.task + "|" + key;
aPrincipal.appId + '|' +
aPrincipal.isInBrowserElement + '|' +
aPrincipal.originNoSuffix;
let data = { principal: aPrincipal, let data = { principal: aPrincipal,
dbKey: dbKey, dbKey: dbKey,