You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2015/12/04 10:29:15 UTC

ios commit: CB-10106 - added bridge proxy

Repository: cordova-ios
Updated Branches:
  refs/heads/master b89cd7158 -> f2e056e5f


CB-10106 - added bridge proxy


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

Branch: refs/heads/master
Commit: f2e056e5fe945801b518b752871f5c64c0a28a88
Parents: b89cd71
Author: Shazron Abdullah <sh...@apache.org>
Authored: Fri Dec 4 01:29:04 2015 -0800
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Fri Dec 4 01:29:04 2015 -0800

----------------------------------------------------------------------
 CordovaLib/cordova.js  | 48 +++++++++++++++++++++++++++++++++------------
 cordova-js-src/exec.js | 42 ++++++++++++++++++++++++++++++---------
 2 files changed, 69 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/f2e056e5/CordovaLib/cordova.js
----------------------------------------------------------------------
diff --git a/CordovaLib/cordova.js b/CordovaLib/cordova.js
index 9945d86..a162778 100644
--- a/CordovaLib/cordova.js
+++ b/CordovaLib/cordova.js
@@ -1,5 +1,5 @@
 // Platform: ios
-// 8e9610fe33fc743fcaf5d920064f0deb2cad1715
+// ded62dda172755defaf75378ed007dc05730ec22
 /*
  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements.  See the NOTICE file
@@ -817,7 +817,7 @@ module.exports = channel;
 
 });
 
-// file: /Users/shaz/Documents/Git/Apache/cordova-ios/cordova-js-src/exec.js
+// file: /Users/shazron/Documents/git/apache/cordova-ios/cordova-js-src/exec.js
 define("cordova/exec", function(require, exports, module) {
 
 /*global require, module, atob, document */
@@ -935,8 +935,9 @@ function iOSExec() {
     }
 }
 
+// CB-10106
 function handleBridgeChange() {
-    if (iOSExec !== cordova.exec) {
+    if (execProxy !== cordovaExec()) {
         var commandString = commandQueue.shift();
         while(commandString) {
             var command = JSON.parse(commandString);
@@ -946,7 +947,7 @@ function handleBridgeChange() {
             var actionArgs = command[3];
             var callbacks = cordova.callbacks[callbackId] || {};
             
-            cordova.exec(callbacks.success, callbacks.fail, service, action, actionArgs);
+            execProxy(callbacks.success, callbacks.fail, service, action, actionArgs);
             
             commandString = commandQueue.shift();
         };
@@ -954,13 +955,9 @@ function handleBridgeChange() {
     }
     
     return false;
-}     
+}
 
 function pokeNative() {
-    if (handleBridgeChange()) {
-        return;
-    }
-    
     // CB-5488 - Don't attempt to create iframe before document.body is available.
     if (!document.body) {
         setTimeout(pokeNative);
@@ -985,7 +982,10 @@ function pokeNative() {
     // navigation of the page).
     failSafeTimerId = setTimeout(function() {
         if (commandQueue.length) {
-            pokeNative();
+            // CB-10106 - flush the queue on bridge change
+            if (!handleBridgeChange()) {
+                pokeNative();
+             }
         }
     }, 50); // Making this > 0 improves performance (marginally) in the normal case (where it doesn't fire).
 }
@@ -1027,7 +1027,31 @@ iOSExec.nativeEvalAndFetch = function(func) {
     }
 };
 
-module.exports = iOSExec;
+// Proxy the exec for bridge changes. See CB-10106
+
+function cordovaExec() {
+    var cexec = require('cordova/exec');
+    var cexec_valid = (typeof cexec.nativeFetchMessages === 'function') && (typeof cexec.nativeEvalAndFetch === 'function') && (typeof cexec.nativeCallback === 'function');
+    return (cexec_valid && execProxy !== cexec)? cexec : iOSExec;
+}
+
+function execProxy() {
+    cordovaExec().apply(null, arguments);
+};
+
+execProxy.nativeFetchMessages = function() {
+    return cordovaExec().nativeFetchMessages.apply(null, arguments);
+};
+
+execProxy.nativeEvalAndFetch = function() {
+    return cordovaExec().nativeEvalAndFetch.apply(null, arguments);
+};
+
+execProxy.nativeCallback = function() {
+    return cordovaExec().nativeCallback.apply(null, arguments);
+};
+
+module.exports = execProxy;
 
 });
 
@@ -1512,7 +1536,7 @@ exports.reset();
 
 });
 
-// file: /Users/shaz/Documents/Git/Apache/cordova-ios/cordova-js-src/platform.js
+// file: /Users/shazron/Documents/git/apache/cordova-ios/cordova-js-src/platform.js
 define("cordova/platform", function(require, exports, module) {
 
 module.exports = {

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/f2e056e5/cordova-js-src/exec.js
----------------------------------------------------------------------
diff --git a/cordova-js-src/exec.js b/cordova-js-src/exec.js
index 155f2ba..06cb1c2 100644
--- a/cordova-js-src/exec.js
+++ b/cordova-js-src/exec.js
@@ -134,8 +134,9 @@ function iOSExec() {
     }
 }
 
+// CB-10106
 function handleBridgeChange() {
-    if (iOSExec !== cordova.exec) {
+    if (execProxy !== cordovaExec()) {
         var commandString = commandQueue.shift();
         while(commandString) {
             var command = JSON.parse(commandString);
@@ -145,7 +146,7 @@ function handleBridgeChange() {
             var actionArgs = command[3];
             var callbacks = cordova.callbacks[callbackId] || {};
             
-            cordova.exec(callbacks.success, callbacks.fail, service, action, actionArgs);
+            execProxy(callbacks.success, callbacks.fail, service, action, actionArgs);
             
             commandString = commandQueue.shift();
         };
@@ -153,13 +154,9 @@ function handleBridgeChange() {
     }
     
     return false;
-}     
+}
 
 function pokeNative() {
-    if (handleBridgeChange()) {
-        return;
-    }
-    
     // CB-5488 - Don't attempt to create iframe before document.body is available.
     if (!document.body) {
         setTimeout(pokeNative);
@@ -184,7 +181,10 @@ function pokeNative() {
     // navigation of the page).
     failSafeTimerId = setTimeout(function() {
         if (commandQueue.length) {
-            pokeNative();
+            // CB-10106 - flush the queue on bridge change
+            if (!handleBridgeChange()) {
+                pokeNative();
+             }
         }
     }, 50); // Making this > 0 improves performance (marginally) in the normal case (where it doesn't fire).
 }
@@ -226,4 +226,28 @@ iOSExec.nativeEvalAndFetch = function(func) {
     }
 };
 
-module.exports = iOSExec;
+// Proxy the exec for bridge changes. See CB-10106
+
+function cordovaExec() {
+    var cexec = require('cordova/exec');
+    var cexec_valid = (typeof cexec.nativeFetchMessages === 'function') && (typeof cexec.nativeEvalAndFetch === 'function') && (typeof cexec.nativeCallback === 'function');
+    return (cexec_valid && execProxy !== cexec)? cexec : iOSExec;
+}
+
+function execProxy() {
+    cordovaExec().apply(null, arguments);
+};
+
+execProxy.nativeFetchMessages = function() {
+    return cordovaExec().nativeFetchMessages.apply(null, arguments);
+};
+
+execProxy.nativeEvalAndFetch = function() {
+    return cordovaExec().nativeEvalAndFetch.apply(null, arguments);
+};
+
+execProxy.nativeCallback = function() {
+    return cordovaExec().nativeCallback.apply(null, arguments);
+};
+
+module.exports = execProxy;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org