Merge fx-team to m-c.
authorRyan VanderMeulen <ryanvm@gmail.com>
Tue, 23 Jul 2013 16:12:03 -0400
changeset 151860 7c20e8e4e56e8b7c8def7d13ed42399f8ff8024d
parent 151857 1121bb73e739a9571ce961d178777b44d24033b0 (diff)
parent 151859 70df083d054752a73386a631421184ad9840bbd3 (current diff)
child 151931 2983ca6d4d1aa0b425db2bfbd49e9efe338685da
child 151967 03bd96d6d76998aa52253124a5b68ec8122c87d5
child 152056 6cf1c69e3fcfa8b1dab2f49882a77f11b28f0c5d
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone25.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
Merge fx-team to m-c.
--- a/b2g/config/gaia.json
+++ b/b2g/config/gaia.json
@@ -1,4 +1,4 @@
 {
-    "revision": "d39f167ee1b770d2312a7b35bbcb29afe83b5c4f", 
+    "revision": "5c08f3d8a2b96b15b232dae43a2428fcdca61a79", 
     "repo_path": "/integration/gaia-central"
 }
--- a/b2g/config/leo/releng-leo.tt
+++ b/b2g/config/leo/releng-leo.tt
@@ -1,12 +1,12 @@
 [
 {
-"size": 141304652,
-"digest": "0bbba7483a483803fa0277ddeeb3f8f9592b57cb83d57794c366fb8a3541b47f0ab901c071b7ceb6828bceec7170e5d5c05c5b1dcc926c70f3da46a7e224f078",
+"size": 117247732,
+"digest": "16e74278e4e9b0d710df77d68af1677c91823dccfc611ab00ee617298a63787f9f9892bd1a41eccb8d45fb18d61bfda0dbd1de88f1861c14b4b44da3b94a4eca",
 "algorithm": "sha512",
 "filename": "backup-leo.tar.xz"
 },
 {
 "size": 1570553,
 "digest": "ea03de74df73b05e939c314cd15c54aac7b5488a407b7cc4f5f263f3049a1f69642c567dd35c43d0bc3f0d599d0385a26ab2dd947a6b18f9044e4918b382eea7",
 "algorithm": "sha512",
 "filename": "Adreno200-AU_LINUX_ANDROID_ICS_CHOCO_CS.04.00.03.06.001.zip"
--- a/dom/apps/src/Webapps.jsm
+++ b/dom/apps/src/Webapps.jsm
@@ -2540,41 +2540,16 @@ this.DOMApplicationRegistry = {
                                                 aManifest._manifest)) {
                   throw "MANIFEST_MISMATCH";
                 }
 
                 if (!AppsUtils.checkInstallAllowed(manifest, aApp.installOrigin)) {
                   throw "INSTALL_FROM_DENIED";
                 }
 
-                // Get ids.json if the file is signed
-                if (isSigned) {
-                  let idsStream;
-                  try {
-                    idsStream = zipReader.getInputStream("META-INF/ids.json");
-                  } catch (e) {
-                    throw zipReader.hasEntry("META-INF/ids.json")
-                          ? e
-                          : "MISSING_IDS_JSON";
-                  }
-                  let ids =
-                    JSON.parse(
-                      converter.ConvertToUnicode(
-                        NetUtil.readInputStreamToString(
-                          idsStream, idsStream.available()) || ""));
-                  if ((!ids.id) || !Number.isInteger(ids.version) ||
-                      (ids.version <= 0)) {
-                     throw "INVALID_IDS_JSON";
-                  }
-                  let storeId = aApp.installOrigin + "#" + ids.id;
-                  checkForStoreIdMatch(storeId, ids.version);
-                  app.storeId = storeId;
-                  app.storeVersion = ids.version;
-                }
-
                 let maxStatus = isSigned ? Ci.nsIPrincipal.APP_STATUS_PRIVILEGED
                                          : Ci.nsIPrincipal.APP_STATUS_INSTALLED;
 
                 if (AppsUtils.getAppManifestStatus(manifest) > maxStatus) {
                   throw "INVALID_SECURITY_LEVEL";
                 }
                 app.appStatus = AppsUtils.getAppManifestStatus(manifest);
 
@@ -2609,48 +2584,77 @@ this.DOMApplicationRegistry = {
                   } catch(e) {
                     throw "INVALID_ORIGIN";
                   }
 
                   if (uri.scheme != "app") {
                     throw "INVALID_ORIGIN";
                   }
 
-                  // Changing the origin during an update is not allowed.
-                  if (aIsUpdate && uri.prePath != app.origin) {
-                    throw "INVALID_ORIGIN_CHANGE";
-                  }
-
-                  debug("Setting origin to " + uri.prePath +
-                        " for " + app.manifestURL);
-                  let newId = uri.prePath.substring(6); // "app://".length
-
-                  if (newId in self.webapps) {
-                    throw "DUPLICATE_ORIGIN";
+                  if (aIsUpdate) {
+                    // Changing the origin during an update is not allowed.
+                    if (uri.prePath != app.origin) {
+                      throw "INVALID_ORIGIN_CHANGE";
+                    }
+                    // Nothing else to do for an update... since the
+                    // origin can't change we don't need to move the
+                    // app nor can we have a duplicated origin
+                  } else {
+                    debug("Setting origin to " + uri.prePath +
+                          " for " + app.manifestURL);
+                    let newId = uri.prePath.substring(6); // "app://".length
+
+                    if (newId in self.webapps) {
+                      throw "DUPLICATE_ORIGIN";
+                    }
+                    app.origin = uri.prePath;
+
+                    app.id = newId;
+                    self.webapps[newId] = app;
+                    delete self.webapps[id];
+
+                    // Rename the directories where the files are installed.
+                    [DIRECTORY_NAME, "TmpD"].forEach(function(aDir) {
+                        let parent = FileUtils.getDir(aDir,
+                          ["webapps"], true, true);
+                        let dir = FileUtils.getDir(aDir,
+                          ["webapps", id], true, true);
+                        dir.moveTo(parent, newId);
+                    });
+
+                    // Signals that we need to swap the old id with the new app.
+                    self.broadcastMessage("Webapps:RemoveApp", { id: id });
+                    self.broadcastMessage("Webapps:AddApp", { id: newId,
+                                                              app: app });
                   }
-                  app.origin = uri.prePath;
-
-                  // Update the registry.
-                  app.id = newId;
-                  self.webapps[newId] = app;
-                  delete self.webapps[id];
-
-                  // Rename the directories where the files are installed.
-                  [DIRECTORY_NAME, "TmpD"].forEach(function(aDir) {
-                    let parent = FileUtils.getDir(aDir,
-                                             ["webapps"], true, true);
-                    let dir = FileUtils.getDir(aDir,
-                                             ["webapps", id], true, true);
-                    dir.moveTo(parent, newId);
-                  });
-
-                  // Signals that we need to swap the old id with the new app.
-                  self.broadcastMessage("Webapps:RemoveApp", { id: id });
-                  self.broadcastMessage("Webapps:AddApp", { id: newId,
-                                                            app: app });
+                }
+
+                // Get ids.json if the file is signed
+                if (isSigned) {
+                  let idsStream;
+                  try {
+                    idsStream = zipReader.getInputStream("META-INF/ids.json");
+                  } catch (e) {
+                    throw zipReader.hasEntry("META-INF/ids.json")
+                          ? e
+                          : "MISSING_IDS_JSON";
+                  }
+                  let ids =
+                    JSON.parse(
+                      converter.ConvertToUnicode(
+                        NetUtil.readInputStreamToString(
+                          idsStream, idsStream.available()) || ""));
+                  if ((!ids.id) || !Number.isInteger(ids.version) ||
+                      (ids.version <= 0)) {
+                     throw "INVALID_IDS_JSON";
+                  }
+                  let storeId = aApp.installOrigin + "#" + ids.id;
+                  checkForStoreIdMatch(storeId, ids.version);
+                  app.storeId = storeId;
+                  app.storeVersion = ids.version;
                 }
 
                 if (aOnSuccess) {
                   aOnSuccess(app.id, manifest);
                 }
               } catch (e) {
                 // Something bad happened when reading the package.
                 // Unrecoverable error, don't bug the user.
--- a/dom/browser-element/BrowserElementChildPreload.js
+++ b/dom/browser-element/BrowserElementChildPreload.js
@@ -259,18 +259,19 @@ BrowserElementChild.prototype = {
                              /* ownsWeak = */ true);
 
     Services.obs.addObserver(this,
                              'xpcom-shutdown',
                              /* ownsWeak = */ true);
   },
 
   observe: function(subject, topic, data) {
-    // Ignore notifications not about our document.
-    if (subject != content.document)
+    // Ignore notifications not about our document.  (Note that |content| /can/
+    // be null; see bug 874900.)
+    if (!content || subject != content.document)
       return;
     switch (topic) {
       case 'fullscreen-origin-change':
         sendAsyncMsg('fullscreen-origin-change', { _payload_: data });
         break;
       case 'ask-parent-to-exit-fullscreen':
         sendAsyncMsg('exit-fullscreen');
         break;
--- a/dom/system/gonk/AutoMounter.cpp
+++ b/dom/system/gonk/AutoMounter.cpp
@@ -13,16 +13,17 @@
 #include <arpa/inet.h>
 #include <linux/types.h>
 #include <linux/netlink.h>
 #include <netinet/in.h>
 #include <sys/socket.h>
 #include <android/log.h>
 
 #include "AutoMounter.h"
+#include "nsVolumeService.h"
 #include "AutoMounterSetting.h"
 #include "base/message_loop.h"
 #include "mozilla/FileUtils.h"
 #include "mozilla/Hal.h"
 #include "mozilla/StaticPtr.h"
 #include "nsAutoPtr.h"
 #include "nsMemory.h"
 #include "nsString.h"
@@ -562,19 +563,78 @@ public:
         FROM_HERE,
         NewRunnableFunction(UsbCableEventIOThread));
   }
 };
 
 static StaticRefPtr<UsbCableObserver> sUsbCableObserver;
 static StaticRefPtr<AutoMounterSetting> sAutoMounterSetting;
 
+static void
+InitVolumeConfig()
+{
+  // This function uses /system/etc/volume.cfg to add additional volumes
+  // to the Volume Manager.
+  //
+  // This is useful on devices like the Nexus 4, which have no physical sd card
+  // or dedicated partition.
+  //
+  // The format of the volume.cfg file is as follows:
+  // create volume-name mount-point
+  // Blank lines and lines starting with the hash character "#" will be ignored.
+
+  nsCOMPtr<nsIVolumeService> vs = do_GetService(NS_VOLUMESERVICE_CONTRACTID);
+  NS_ENSURE_TRUE_VOID(vs);
+
+  ScopedCloseFile fp;
+  int n = 0;
+  char line[255];
+  char *command, *vol_name_cstr, *mount_point_cstr, *save_ptr;
+  const char *filename = "/system/etc/volume.cfg";
+  if (!(fp = fopen(filename, "r"))) {
+    LOG("Unable to open volume configuration file '%s' - ignoring", filename);
+    return;
+  }
+  while(fgets(line, sizeof(line), fp)) {
+    char *delim = " \t\n";
+    n++;
+
+    if (line[0] == '#')
+      continue;
+    if (!(command = strtok_r(line, delim, &save_ptr))) {
+      // Blank line - ignore
+      continue;
+    }
+    if (!strcmp(command, "create")) {
+      if (!(vol_name_cstr = strtok_r(NULL, delim, &save_ptr))) {
+        ERR("No vol_name in %s line %d",  filename, n);
+        continue;
+      }
+      if (!(mount_point_cstr = strtok_r(NULL, delim, &save_ptr))) {
+        ERR("No mount point for volume '%s'. %s line %d", vol_name_cstr, filename, n);
+        continue;
+      }
+      nsString  mount_point = NS_ConvertUTF8toUTF16(mount_point_cstr);
+      nsString vol_name = NS_ConvertUTF8toUTF16(vol_name_cstr);
+      nsresult rv;
+      rv = vs->CreateFakeVolume(vol_name, mount_point);
+      NS_ENSURE_SUCCESS_VOID(rv);
+      rv = vs->SetFakeVolumeState(vol_name, nsIVolume::STATE_MOUNTED);
+      NS_ENSURE_SUCCESS_VOID(rv);
+    }
+    else {
+      ERR("Unrecognized command: '%s'", command);
+    }
+  }
+}
+
 void
 InitAutoMounter()
 {
+  InitVolumeConfig();
   InitVolumeManager();
   sAutoMounterSetting = new AutoMounterSetting();
 
   XRE_GetIOMessageLoop()->PostTask(
       FROM_HERE,
       NewRunnableFunction(InitAutoMounterIOThread));
 
   // Switch Observers need to run on the main thread, so we need to
--- a/xpcom/glue/FileUtils.h
+++ b/xpcom/glue/FileUtils.h
@@ -63,16 +63,29 @@ struct ScopedClosePRFDTraits
   static void release(type fd) {
     if (fd != NULL) {
       PR_Close(fd);
     }
   }
 };
 typedef Scoped<ScopedClosePRFDTraits> AutoFDClose;
 
+/* RAII wrapper for FILE descriptors */
+struct ScopedCloseFileTraits
+{
+  typedef FILE *type;
+  static type empty() { return nullptr; }
+  static void release(type f) {
+    if (f) {
+      fclose(f);
+    }
+  }
+};
+typedef Scoped<ScopedCloseFileTraits> ScopedCloseFile;
+
 /**
  * Fallocate efficiently and continuously allocates files via fallocate-type APIs.
  * This is useful for avoiding fragmentation.
  * On sucess the file be padded with zeros to grow to aLength.
  *
  * @param aFD file descriptor.
  * @param aLength length of file to grow to.
  * @return true on success.