You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/12/20 05:06:59 UTC

[2/3] js commit: Revert "CB-5134 iOS - Add location.hash-based exec bridge."

Revert "CB-5134 iOS - Add location.hash-based exec bridge."

This reverts commit 2c93179f5d7c72883bda37f559cb6ee701b5763f.


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/775d2b4b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/775d2b4b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/775d2b4b

Branch: refs/heads/master
Commit: 775d2b4bc18688913d6f4e733bbbebff2c993164
Parents: 3fc7ee4
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Dec 19 22:56:06 2013 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Dec 19 22:56:06 2013 -0500

----------------------------------------------------------------------
 src/ios/exec.js | 31 +++++--------------------------
 1 file changed, 5 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/775d2b4b/src/ios/exec.js
----------------------------------------------------------------------
diff --git a/src/ios/exec.js b/src/ios/exec.js
index 07f7c7d..c3e7689 100644
--- a/src/ios/exec.js
+++ b/src/ios/exec.js
@@ -29,17 +29,11 @@ var cordova = require('cordova'),
     channel = require('cordova/channel'),
     utils = require('cordova/utils'),
     base64 = require('cordova/base64'),
-    // XHR mode does not work on iOS 4.2, so default to IFRAME_NAV for such devices.
-    // XHR mode's main advantage is working around a bug in -webkit-scroll, which
-    // doesn't exist in 4.X devices anyways.
-    // HASH_* modes are newer and better in every way :)
     jsToNativeModes = {
         IFRAME_NAV: 0,
         XHR_NO_PAYLOAD: 1,
         XHR_WITH_PAYLOAD: 2,
-        XHR_OPTIONAL_PAYLOAD: 3,
-        HASH_NO_PAYLOAD: 4,
-        HASH_OPTIONAL_PAYLOAD: 5
+        XHR_OPTIONAL_PAYLOAD: 3
     },
     bridgeMode,
     execIframe,
@@ -49,9 +43,6 @@ var cordova = require('cordova'),
     commandQueue = [], // Contains pending JS->Native messages.
     isInContextOfEvalJs = 0;
 
-// TODO: Play with this number.
-var MAX_HASH_PAYLOAD_LENGTH = 4000;
-
 function createExecIframe() {
     var iframe = document.createElement("iframe");
     iframe.style.display = 'none';
@@ -63,13 +54,13 @@ function shouldBundleCommandJson() {
     if (bridgeMode == jsToNativeModes.XHR_WITH_PAYLOAD) {
         return true;
     }
-    if (bridgeMode == jsToNativeModes.XHR_OPTIONAL_PAYLOAD || jsToNativeModes.HASH_OPTIONAL_PAYLOAD) {
+    if (bridgeMode == jsToNativeModes.XHR_OPTIONAL_PAYLOAD) {
         var payloadLength = 0;
         for (var i = 0; i < commandQueue.length; ++i) {
             payloadLength += commandQueue[i].length;
         }
         // The value here was determined using the benchmark within CordovaLibApp on an iPad 3.
-        return payloadLength < (bridgeMode == jsToNativeModes.XHR_OPTIONAL_PAYLOAD ? 4500 : MAX_HASH_PAYLOAD_LENGTH);
+        return payloadLength < 4500;
     }
     return false;
 }
@@ -183,10 +174,7 @@ function iOSExec() {
     // Also, if there is already a command in the queue, then we've already
     // poked the native side, so there is no reason to do so again.
     if (!isInContextOfEvalJs && commandQueue.length == 1) {
-        switch (bridgeMode) {
-        case jsToNativeModes.XHR_NO_PAYLOAD:
-        case jsToNativeModes.XHR_WITH_PAYLOAD:
-        case jsToNativeModes.XHR_OPTIONAL_PAYLOAD:
+        if (bridgeMode != jsToNativeModes.IFRAME_NAV) {
             // This prevents sending an XHR when there is already one being sent.
             // This should happen only in rare circumstances (refer to unit tests).
             if (execXhr && execXhr.readyState != 4) {
@@ -207,16 +195,7 @@ function iOSExec() {
                 execXhr.setRequestHeader('cmds', iOSExec.nativeFetchMessages());
             }
             execXhr.send(null);
-            break;
-        case jsToNativeModes.HASH_NO_PAYLOAD:
-        case jsToNativeModes.HASH_OPTIONAL_PAYLOAD:
-            var hashValue = '%01';
-            if (shouldBundleCommandJson()) {
-                hashValue += iOSExec.nativeFetchMessages();
-            }
-            location.hash = hashValue;
-            break;
-        default:
+        } else {
             execIframe = execIframe || createExecIframe();
             execIframe.src = "gap://ready";
         }