Bug 767023 - Change "deleted" to "hidden" per spec change; r=rnewman
authorGregory Szorc <gps@mozilla.com>
Sat, 23 Jun 2012 10:22:53 -0700
changeset 102971 7b97f42c3a591c2e50aff2d1360dfee63534db1d
parent 102970 6cb0f670716839a09bbe8f925424dc3be1f48dae
child 102972 be373f4b243feda9d4b2942c690b055611e635f0
push id191
push userlsblakk@mozilla.com
push dateFri, 05 Oct 2012 17:12:53 +0000
treeherdermozilla-release@ddb22ac6c03b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman
bugs767023
milestone16.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 767023 - Change "deleted" to "hidden" per spec change; r=rnewman
dom/apps/src/Webapps.jsm
services/aitc/modules/client.js
services/aitc/modules/manager.js
services/aitc/modules/storage.js
services/aitc/tests/unit/test_storage_registry.js
services/common/tests/unit/aitcserver.js
--- a/dom/apps/src/Webapps.jsm
+++ b/dom/apps/src/Webapps.jsm
@@ -394,17 +394,17 @@ let DOMApplicationRegistry = {
       result[id] = app;
     }
     aCallback(result);
   },
 
   updateApps: function(aRecords, aCallback) {
     for (let i = 0; i < aRecords.length; i++) {
       let record = aRecords[i];
-      if (record.deleted) {
+      if (record.hidden) {
         if (!this.webapps[record.id])
           continue;
         let origin = this.webapps[record.id].origin;
         delete this.webapps[record.id];
         let dir = FileUtils.getDir(DIRECTORY_NAME, ["webapps", record.id], true, true);
         try {
           dir.remove(true);
         } catch (e) {
--- a/services/aitc/modules/client.js
+++ b/services/aitc/modules/client.js
@@ -92,17 +92,17 @@ AitcClient.prototype = {
    */
   remoteUninstall: function remoteUninstall(app, cb) {
     if (!cb) {
       throw new Error("remoteUninstall called without callback");
     }
 
     app.name = "Uninstalled"; // Bug 760262
     let record = this._makeRemoteApp(app);
-    record.deleted = true;
+    record.hidden = true;
     this._putApp(record, cb);
   },
 
   /**
    * Fetch remote apps from server with GET. The provided callback will receive
    * an array of app objects in the format expected by DOMApplicationRegistry,
    * if successful, or an Error; in the usual (err, result) way.
    */
@@ -230,18 +230,18 @@ AitcClient.prototype = {
     let record = {
       origin:         app.origin,
       installOrigin:  app.installOrigin,
       installedAt:    app.installedAt,
       modifiedAt:     app.modifiedAt,
       manifestURL:    app.manifestPath,
       receipts:       app.receipts
     };
-    if ("deleted" in app) {
-      record.deleted = app.deleted;
+    if ("hidden" in app) {
+      record.hidden = app.hidden;
     }
     return record;
   },
 
   /**
    * Try PUT for an app on the server and determine if we should retry
    * if it fails.
    */
@@ -379,9 +379,9 @@ AitcClient.prototype = {
     if (backoff) {
       this._backoff = true;
       let time = Date.now();
       // Fuzz backoff time so all client don't retry at the same time
       backoff = Math.floor((Math.random() * backoff + backoff) * 1000);
       this._state.set("backoff", "" + (time + backoff));
     }
   },
-};
\ No newline at end of file
+};
--- a/services/aitc/modules/manager.js
+++ b/services/aitc/modules/manager.js
@@ -377,17 +377,17 @@ AitcManager.prototype = {
       self._processQueue();
     }
 
     switch (record.type) {
       case "install":
         this._client.remoteInstall(record.app, _clientCallback);
         break;
       case "uninstall":
-        record.app.deleted = true;
+        record.app.hidden = true;
         this._client.remoteUninstall(record.app, _clientCallback);
         break;
       default:
         this._log.warn(
           "Unrecognized type " + record.type + " in queue, removing"
         );
         let self = this;
         this._pending.dequeue(function _dequeued(err) {
--- a/services/aitc/modules/storage.js
+++ b/services/aitc/modules/storage.js
@@ -252,35 +252,35 @@ AitcStorageImpl.prototype = {
    * Take a list of remote and local apps and figured out what changes (if any)
    * are to be made to the local DOMApplicationRegistry.
    *
    * General algorithm:
    *  1. Put all remote apps in a dictionary of origin->app.
    *  2. Put all local apps in a dictionary of origin->app.
    *  3. Mark all local apps as "to be deleted".
    *  4. Go through each remote app:
-   *    4a. If remote app is not marked as deleted, remove from the "to be
+   *    4a. If remote app is not marked as hidden, remove from the "to be
    *        deleted" set.
-   *    4b. If remote app is marked as deleted, but isn't present locally,
+   *    4b. If remote app is marked as hidden, but isn't present locally,
    *        process the next remote app.
-   *    4c. If remote app is not marked as deleted and isn't present locally,
+   *    4c. If remote app is not marked as hidden and isn't present locally,
    *        add to the "to be installed" set.
    *  5. For each app either in the "to be installed" or "to be deleted" set,
    *     apply the changes locally. For apps to be installed, we must also
    *     fetch the manifest.
    *
    */
   _processApps: function _processApps(remoteApps, lApps, callback) {
     let toDelete = {};
     let localApps = {};
 
     // If remoteApps is empty, do nothing. The correct thing to do is to
     // delete all local apps, but we'll play it safe for now since we are
     // marking apps as deleted anyway. In a subsequent version (when the
-    // deleted flag is no longer in use), this check can be removed.
+    // hidden flag is no longer in use), this check can be removed.
     if (!Object.keys(remoteApps).length) {
       this._log.warn("Empty set of remote apps to _processApps, returning");
       callback();
       return;
     }
 
     // Convert lApps to a dictionary of origin -> app (instead of id -> app).
     for (let [id, app] in Iterator(lApps)) {
@@ -289,22 +289,22 @@ AitcStorageImpl.prototype = {
       localApps[app.origin] = app;
     }
 
     // Iterate over remote apps, and find out what changes we must apply.
     let toInstall = [];
     for each (let app in remoteApps) {
       // Don't delete apps that are both local & remote.
       let origin = app.origin;
-      if (!app.deleted) {
+      if (!app.hidden) {
         delete toDelete[origin];
       }
 
-      // A remote app that was deleted, but also isn't present locally is NOP.
-      if (app.deleted && !localApps[origin]) {
+      // A remote app that was hidden, but also isn't present locally is NOP.
+      if (app.hidden && !localApps[origin]) {
         continue;
       }
 
       // If there is a remote app that isn't local or if the remote app was
       // installed or updated later.
       let id;
       if (!localApps[origin]) {
         id = DOMApplicationRegistry.makeAppId();
@@ -315,20 +315,20 @@ AitcStorageImpl.prototype = {
       }
 
       // We should (re)install this app locally
       if (id) {
         toInstall.push({id: id, value: app});
       }
     }
 
-    // Uninstalls only need the ID & deleted flag.
+    // Uninstalls only need the ID & hidden flag.
     let toUninstall = [];
     for (let origin in toDelete) {
-      toUninstall.push({id: toDelete[origin].id, deleted: true});
+      toUninstall.push({id: toDelete[origin].id, hidden: true});
     }
 
     // Apply uninstalls first, we do not need to fetch manifests.
     if (toUninstall.length) {
       this._log.info("Applying uninstalls to registry");
 
       let self = this;
       DOMApplicationRegistry.updateApps(toUninstall, function() {
@@ -444,9 +444,9 @@ AitcStorageImpl.prototype = {
       callback(err, manifest);
     });
   },
 
 };
 
 XPCOMUtils.defineLazyGetter(this, "AitcStorage", function() {
   return new AitcStorageImpl();
-});
\ No newline at end of file
+});
--- a/services/aitc/tests/unit/test_storage_registry.js
+++ b/services/aitc/tests/unit/test_storage_registry.js
@@ -71,16 +71,17 @@ function create_servers() {
       res.setStatusLine(req.httpVersion, 200, "OK");
       res.setHeader("Content-Type", "application/x-web-app-manifest+json");
       res.bodyOutputStream.write(response, response.length);
     }}, START_PORT + i);
   }
 }
 
 function run_test() {
+  initTestLogging();
   create_servers();
   run_next_test();
 }
 
 add_test(function test_storage_install() {
   let apps = [fakeApp1, fakeApp2];
   AitcStorage.processApps(apps, function() {
     // Verify that app1 got added to registry
@@ -99,26 +100,26 @@ add_test(function test_storage_install()
       do_check_eq(DOMApplicationRegistry.itemExists(id1), true);
       do_check_eq(DOMApplicationRegistry.itemExists(id2), true);
       run_next_test();
     });
   });
 });
 
 add_test(function test_storage_uninstall() {
-  // Set app1 as deleted.
-  fakeApp1.deleted = true;
+  // Set app1 as hidden.
+  fakeApp1.hidden = true;
   AitcStorage.processApps([fakeApp2], function() {
     // It should be missing.
     do_check_eq(DOMApplicationRegistry._appId(fakeApp1.origin), null);
     run_next_test();
   });
 });
 
 add_test(function test_storage_uninstall_empty() {
   // Now remove app2 by virtue of it missing in the remote list.
   AitcStorage.processApps([fakeApp3], function() {
     let id3 = DOMApplicationRegistry._appId(fakeApp3.origin);
     do_check_eq(DOMApplicationRegistry.itemExists(id3), true);
     do_check_eq(DOMApplicationRegistry._appId(fakeApp2.origin), null);
     run_next_test();
   });
-});
\ No newline at end of file
+});
--- a/services/common/tests/unit/aitcserver.js
+++ b/services/common/tests/unit/aitcserver.js
@@ -33,17 +33,17 @@ AITCServer10User.prototype = {
   appRecordProperties: {
     origin:        true,
     manifestPath:  true,
     installOrigin: true,
     installedAt:   true,
     modifiedAt:    true,
     receipts:      true,
     name:          true,
-    deleted:       true,
+    hidden:        true,
   },
 
   requiredAppProperties: [
     "origin",
     "manifestPath",
     "installOrigin",
     "installedAt",
     "modifiedAt",