Backout f4c32db7c7d6 for not landing on top of the right cset.
authorRyan VanderMeulen <ryanvm@gmail.com>
Sat, 20 Oct 2012 07:53:27 -0400
changeset 116226 edadf84382ce6749f062a492699b8a72ce4e7372
parent 116225 db0f6c3046b205608a84f67e8544040ec7153c15
child 116227 bfde44cc9eadde4f672d9eff66813e997138bdf6
push id1708
push userakeybl@mozilla.com
push dateMon, 19 Nov 2012 21:10:21 +0000
treeherdermozilla-beta@27b14fe50103 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone18.0a2
backs outf4c32db7c7d6af19a287ed086d488532ba96e4a8
Backout f4c32db7c7d6 for not landing on top of the right cset.
dom/messages/SystemMessageInternal.js
--- a/dom/messages/SystemMessageInternal.js
+++ b/dom/messages/SystemMessageInternal.js
@@ -84,32 +84,22 @@ SystemMessageInternal.prototype = {
                                    { type: aType,
                                      msg: aMessage,
                                      manifest: aManifestURI.spec,
                                      uri: aPageURI.spec,
                                      msgID: messageID })
       });
     }
 
-    let pagesToOpen = {};
     this._pages.forEach(function(aPage) {
       if (!this._isPageMatched(aPage, aType, aPageURI.spec, aManifestURI.spec)) {
         return;
       }
 
-      // Queue this message in the corresponding pages.
-      this._queueMessage(aPage, aMessage, messageID);
-
-      // Open app pages to handle their pending messages.
-      // Note that we only need to open each app page once.
-      let key = this._createKeyForPage(aPage);
-      if (!pagesToOpen.hasOwnProperty(key)) {
-        this._openAppPage(aPage, aMessage);
-        pagesToOpen[key] = true;
-      }
+      this._openAppPage(aPage, aMessage, messageID);
     }, this);
   },
 
   broadcastMessage: function broadcastMessage(aType, aMessage) {
     // Buffer system messages until the webapps' registration is ready,
     // so that we can know the correct pages registered to be broadcasted.
     if (!this._webappsRegistryReady) {
       this._bufferedSysMsgs.push({ how: "broadcast",
@@ -119,39 +109,29 @@ SystemMessageInternal.prototype = {
     }
 
     // Give this message an ID so that we can identify the message and
     // clean it up from the pending message queue when apps receive it.
     let messageID = gUUIDGenerator.generateUUID().toString();
 
     debug("Broadcasting " + aType + " " + JSON.stringify(aMessage));
     // Find pages that registered an handler for this type.
-    let pagesToOpen = {};
     this._pages.forEach(function(aPage) {
       if (aPage.type == aType) {
         if (this._listeners[aPage.manifest]) {
           this._listeners[aPage.manifest].forEach(function sendMsg(aListener) {
             aListener.sendAsyncMessage("SystemMessageManager:Message",
                                        { type: aType,
                                          msg: aMessage,
                                          manifest: aPage.manifest,
                                          uri: aPage.uri,
                                          msgID: messageID })
           });
         }
-        // Queue this message in the corresponding pages.
-        this._queueMessage(aPage, aMessage, messageID);
-
-        // Open app pages to handle their pending messages.
-        // Note that we only need to open each app page once.
-        let key = this._createKeyForPage(aPage);
-        if (!pagesToOpen.hasOwnProperty(key)) {
-          this._openAppPage(aPage, aMessage);
-          pagesToOpen[key] = true;
-        }
+        this._openAppPage(aPage, aMessage, messageID);
       }
     }, this);
   },
 
   registerPage: function registerPage(aType, aPageURI, aManifestURI) {
     if (!aPageURI || !aManifestURI) {
       throw Cr.NS_ERROR_INVALID_ARG;
     }
@@ -276,57 +256,37 @@ SystemMessageInternal.prototype = {
               break;
           }
         }, this);
         this._bufferedSysMsgs = null;
         break;
     }
   },
 
-  _queueMessage: function _queueMessage(aPage, aMessage, aMessageID) {
+  _openAppPage: function _openAppPage(aPage, aMessage, aMessageID) {
     // Queue the message for this page because we've never known if an app is
     // opened or not. We'll clean it up when the app has already received it.
     aPage.pendingMessages.push({ msg: aMessage, msgID: aMessageID });
     if (aPage.pendingMessages.length > kMaxPendingMessages) {
       aPage.pendingMessages.splice(0, 1);
     }
-  },
 
-  _openAppPage: function _openAppPage(aPage, aMessage) {
     // We don't need to send the full object to observers.
     let page = { uri: aPage.uri,
                  manifest: aPage.manifest,
                  type: aPage.type,
                  target: aMessage.target };
     debug("Asking to open " + JSON.stringify(page));
     Services.obs.notifyObservers(this, "system-messages-open-app", JSON.stringify(page));
   },
 
   _isPageMatched: function _isPageMatched(aPage, aType, aUri, aManifest) {
     return (aPage.type === aType &&
             aPage.manifest === aManifest &&
             aPage.uri === aUri)
   },
 
-  _createKeyForPage: function _createKeyForPage(aPage) {
-    let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"]
-                      .createInstance(Ci.nsIScriptableUnicodeConverter);
-    converter.charset = "UTF-8";
-
-    let hasher = Cc["@mozilla.org/security/hash;1"]
-                   .createInstance(Ci.nsICryptoHash);
-    hasher.init(hasher.SHA1);
-
-    // add uri and action to the hash
-    ["type", "manifest", "uri"].forEach(function(aProp) {
-      let data = converter.convertToByteArray(aPage[aProp], {});
-      hasher.update(data, data.length);
-    });
-
-    return hasher.finish(true);
-  },
-
   classID: Components.ID("{70589ca5-91ac-4b9e-b839-d6a88167d714}"),
 
   QueryInterface: XPCOMUtils.generateQI([Ci.nsISystemMessagesInternal, Ci.nsIObserver])
 }
 
 const NSGetFactory = XPCOMUtils.generateNSGetFactory([SystemMessageInternal]);