Updated Branches: refs/heads/master 27d9aedd5 -> 47fce0206
[ios] Add request count header to XHR bridge modes. Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/commit/47fce020 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/47fce020 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/47fce020 Branch: refs/heads/master Commit: 47fce02062301efaf3f5b0cc55f68ef1d1a22c06 Parents: 27d9aed Author: Andrew Grieve <agri...@chromium.org> Authored: Wed Oct 3 13:20:35 2012 -0400 Committer: Andrew Grieve <agri...@chromium.org> Committed: Wed Oct 3 13:20:35 2012 -0400 ---------------------------------------------------------------------- lib/ios/exec.js | 16 +++++++--------- 1 files changed, 7 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/47fce020/lib/ios/exec.js ---------------------------------------------------------------------- diff --git a/lib/ios/exec.js b/lib/ios/exec.js index 6635c0b..b58df58 100644 --- a/lib/ios/exec.js +++ b/lib/ios/exec.js @@ -40,7 +40,8 @@ var cordova = require('cordova'), // doesn't exist in 4.X devices anyways. bridgeMode = navigator.userAgent.indexOf(' 4_') == -1 ? jsToNativeModes.XHR_NO_PAYLOAD : jsToNativeModes.IFRAME_NAV, execIframe, - execXhr; + execXhr, + requestCount = 0; function createExecIframe() { var iframe = document.createElement("iframe"); @@ -50,10 +51,10 @@ function createExecIframe() { } function shouldBundleCommandJson() { - if (bridgeMode == 2) { + if (bridgeMode == jsToNativeModes.XHR_WITH_PAYLOAD) { return true; } - if (bridgeMode == 3) { + if (bridgeMode == jsToNativeModes.XHR_OPTIONAL_PAYLOAD) { var payloadLength = 0; for (var i = 0; i < cordova.commandQueue.length; ++i) { payloadLength += cordova.commandQueue[i].length; @@ -109,12 +110,8 @@ function iOSExec() { // the command is executed. cordova.commandQueue.push(JSON.stringify(command)); - // If the queue length is 1, then that means it was empty before we queued - // the given command, so let the native side know that we have some - // commands to execute, unless the queue is currently being flushed, in - // which case the command will be picked up without notification. - if (cordova.commandQueue.length == 1 && !cordova.commandQueueFlushing) { - if (bridgeMode) { + if (!cordova.commandQueueFlushing) { + if (bridgeMode != jsToNativeModes.IFRAME_NAV) { // Re-using the XHR improves exec() performance by about 10%. // It is possible for a native stringByEvaluatingJavascriptFromString call // to cause us to reach this point when a request is already in progress, @@ -128,6 +125,7 @@ function iOSExec() { // For some reason it still doesn't work though... execXhr.open('HEAD', "/!gap_exec", true); execXhr.setRequestHeader('vc', cordova.iOSVCAddr); + execXhr.setRequestHeader('rc', ++requestCount); if (shouldBundleCommandJson()) { execXhr.setRequestHeader('cmds', nativecomm()); }