Bug 1165787 - Use origin in RequestSyncService.jsm. r=ehsan
authorYoshi Huang <allstars.chh@mozilla.com>
Fri, 29 May 2015 19:35:10 +0800
changeset 280412 88458747047560c4b0ead1329fb34bfb6c02ff05
parent 280411 dfcbd19717efcba56e9e9d69ff5ba6f4ce095e92
child 280413 9e9a04143107a224c8b543a5b7a7806aa2f4f829
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-beta@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1165787
milestone41.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 1165787 - Use origin in RequestSyncService.jsm. r=ehsan
dom/requestsync/RequestSyncService.jsm
--- a/dom/requestsync/RequestSyncService.jsm
+++ b/dom/requestsync/RequestSyncService.jsm
@@ -76,17 +76,17 @@ this.RequestSyncService = {
   init: function() {
     debug("init");
 
     this._messages.forEach((function(msgName) {
       ppmm.addMessageListener(msgName, this);
     }).bind(this));
 
     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);
 
     this.initDBHelper("requestSync", RSYNCDB_VERSION, [RSYNCDB_NAME]);
 
     // Loading all the data from the database into the _registrations map.
     // Any incoming message will be stored and processed when the async
     // operation is completed.
 
@@ -112,17 +112,17 @@ this.RequestSyncService = {
   shutdown: function() {
     debug("shutdown");
 
     this._messages.forEach((function(msgName) {
       ppmm.removeMessageListener(msgName, this);
     }).bind(this));
 
     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');
 
     this.close();
 
     // Removing all the registrations will delete the pending timers.
     let self = this;
     this.forEachRegistration(function(aObj) {
       let key = self.principalToKey(aObj.principal);
@@ -133,18 +133,18 @@ this.RequestSyncService = {
   observe: function(aSubject, aTopic, aData) {
     debug("observe");
 
     switch (aTopic) {
       case 'xpcom-shutdown':
         this.shutdown();
         break;
 
-      case 'webapps-clear-data':
-        this.clearData(aSubject);
+      case 'clear-cookiejar-data':
+        this.clearData(aData);
         break;
 
       case 'wifi-state-changed':
         this.wifiStateChanged(aSubject == 'enabled');
         break;
 
       default:
         debug("Wrong observer topic: " + aTopic);
@@ -155,25 +155,17 @@ this.RequestSyncService = {
   // When an app is uninstalled, we have to clean all its tasks.
   clearData: function(aData) {
     debug('clearData');
 
     if (!aData) {
       return;
     }
 
-    let params =
-      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 partialKey = aData;
     let dbKeys = [];
 
     for (let key  in this._registrations) {
       if (key.indexOf(partialKey) != 0) {
         continue;
       }
 
       for (let task in this._registrations[key]) {
@@ -202,19 +194,17 @@ this.RequestSyncService = {
   // Creation of the schema for the database.
   upgradeSchema: function(aTransaction, aDb, aOldVersion, aNewVersion) {
     debug('updateSchema');
     aDb.createObjectStore(RSYNCDB_NAME, { autoIncrement: true });
   },
 
   // This method generates the key for the indexedDB object storage.
   principalToKey: function(aPrincipal) {
-    return aPrincipal.appId + '|' +
-           aPrincipal.isInBrowserElement + '|' +
-           aPrincipal.originNoSuffix;
+    return aPrincipal.cookieJar + '|' + aPrincipal.origin;
   },
 
   // Add a task to the _registrations map and create the timer if it's needed.
   addRegistration: function(aObj) {
     debug('addRegistration');
 
     let key = this.principalToKey(aObj.principal);
     if (!(key in this._registrations)) {
@@ -377,20 +367,17 @@ this.RequestSyncService = {
 
     aData.params.state = RSYNC_STATE_ENABLED;
     if (aData.params.wifiOnly) {
       aData.params.state = RSYNC_STATE_WIFIONLY;
     }
 
     aData.params.overwrittenMinInterval = 0;
 
-    let dbKey = aData.task + "|" +
-                aPrincipal.appId + '|' +
-                aPrincipal.isInBrowserElement + '|' +
-                aPrincipal.originNoSuffix;
+    let dbKey = aData.task + "|" + key;
 
     let data = { principal: aPrincipal,
                  dbKey: dbKey,
                  data: aData.params,
                  active: true };
 
     let self = this;
     this.dbTxn('readwrite', function(aStore) {