Bug 924032 - ~40ms delay from app.launch to mozChromeEvent r=vingtetun
authorFabrice Desré <fabrice@mozilla.com>
Mon, 14 Oct 2013 08:59:28 -0700
changeset 164499 40ea83931670ca260b1e9a5e28b97ccac6ca2735
parent 164498 ffa62b4eeaafbe735ed0eb34d4e072247199d8fe
child 164500 37e925e977cd1fec6a5b731c4e30b8a260877844
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvingtetun
bugs924032
milestone27.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 924032 - ~40ms delay from app.launch to mozChromeEvent r=vingtetun
b2g/chrome/content/shell.js
--- a/b2g/chrome/content/shell.js
+++ b/b2g/chrome/content/shell.js
@@ -524,43 +524,54 @@ var shell = {
   },
 
   sendEvent: function shell_sendEvent(content, type, details) {
     let event = content.document.createEvent('CustomEvent');
     event.initCustomEvent(type, true, true, details ? details : {});
     content.dispatchEvent(event);
   },
 
+  sendCustomEvent: function shell_sendCustomEvent(type, details) {
+    let content = getContentWindow();
+    let event = content.document.createEvent('CustomEvent');
+    let payload = details ? ObjectWrapper.wrap(details, content) : {};
+    event.initCustomEvent(type, true, true, payload);
+    content.dispatchEvent(event);
+  },
+
   sendChromeEvent: function shell_sendChromeEvent(details) {
     if (!this.isHomeLoaded) {
       if (!('pendingChromeEvents' in this)) {
         this.pendingChromeEvents = [];
       }
 
       this.pendingChromeEvents.push(details);
       return;
     }
 
     this.sendEvent(getContentWindow(), "mozChromeEvent",
                    ObjectWrapper.wrap(details, getContentWindow()));
   },
 
   openAppForSystemMessage: function shell_openAppForSystemMessage(msg) {
     let origin = Services.io.newURI(msg.manifest, null, null).prePath;
-    this.sendChromeEvent({
-      type: 'open-app',
+    let payload = {
       url: msg.uri,
       manifestURL: msg.manifest,
       isActivity: (msg.type == 'activity'),
       onlyShowApp: msg.onlyShowApp,
       showApp: msg.showApp,
       target: msg.target,
       expectingSystemMessage: true,
       extra: msg.extra
-    });
+    }
+    this.sendCustomEvent('open-app', payload);
+    // XXX Remove once the gaia part of bug 924032 has landed.
+    payload.type = 'open-app';
+    this.sendChromeEvent(payload);
   },
 
   receiveMessage: function shell_receiveMessage(message) {
     var activities = { 'content-handler': { name: 'view', response: null },
                        'dial-handler':    { name: 'dial', response: null },
                        'mail-handler':    { name: 'new',  response: null },
                        'sms-handler':     { name: 'new',  response: null },
                        'file-picker':     { name: 'pick', response: 'file-picked' } };
@@ -942,37 +953,50 @@ var WebappsHelper = {
 
     switch(topic) {
       case "webapps-launch":
         DOMApplicationRegistry.getManifestFor(json.manifestURL, function(aManifest) {
           if (!aManifest)
             return;
 
           let manifest = new ManifestHelper(aManifest, json.origin);
-          shell.sendChromeEvent({
-            "type": "webapps-launch",
-            "timestamp": json.timestamp,
-            "url": manifest.fullLaunchPath(json.startPoint),
-            "manifestURL": json.manifestURL
-          });
+          let payload = {
+            __exposedProps__: {
+              timestamp: "r",
+              url: "r",
+              manifestURL: "r"
+            },
+            timestamp: json.timestamp,
+            url: manifest.fullLaunchPath(json.startPoint),
+            manifestURL: json.manifestURL
+          }
+          shell.sendEvent(getContentWindow(), "webapps-launch", payload);
+          // XXX Remove once the gaia side of bug 924032 lands.
+          payload.type = "webapps-launch";
+          delete payload.__exposedProps__;
+          shell.sendChromeEvent(payload);
         });
         break;
       case "webapps-ask-install":
         let id = this.registerInstaller(json);
         shell.sendChromeEvent({
           type: "webapps-ask-install",
           id: id,
           app: json.app
         });
         break;
       case "webapps-close":
-        shell.sendChromeEvent({
-          "type": "webapps-close",
-          "manifestURL": json.manifestURL
-        });
+        shell.sendEvent(shell.getContentWindow(), "webapps-close",
+          {
+            __exposedProps__: { "manifestURL": "r" },
+            "manifestURL": json.manifestURL
+          });
+        // XXX Remove once the gaia side of bug 924032 lands.
+        shell.sendChromeEvent({ type: "webapps-close",
+                                "manifestURL": json.manifestURL });
         break;
     }
   }
 }
 
 let IndexedDBPromptHelper = {
   _quotaPrompt: "indexedDB-quota-prompt",
   _quotaResponse: "indexedDB-quota-response",