incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [11/14] android commit: Add constant to disable non-exec() messages in Native->JS bridge.
Date Tue, 18 Sep 2012 17:52:51 GMT
Add constant to disable non-exec() messages in Native->JS bridge.


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/commit/4c9a5711
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/4c9a5711
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/4c9a5711

Branch: refs/heads/master
Commit: 4c9a571106acaed0fd08b7508a956d70a62e61cb
Parents: 365edca
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Tue Sep 11 11:26:31 2012 -0400
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Tue Sep 18 13:24:37 2012 -0400

----------------------------------------------------------------------
 .../org/apache/cordova/NativeToJsMessageQueue.java |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/4c9a5711/framework/src/org/apache/cordova/NativeToJsMessageQueue.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/NativeToJsMessageQueue.java b/framework/src/org/apache/cordova/NativeToJsMessageQueue.java
index 779926d..a118706 100755
--- a/framework/src/org/apache/cordova/NativeToJsMessageQueue.java
+++ b/framework/src/org/apache/cordova/NativeToJsMessageQueue.java
@@ -39,6 +39,10 @@ public class NativeToJsMessageQueue {
     // This must match the default value in incubator-cordova-js/lib/android/exec.js
     private static final int DEFAULT_BRIDGE_MODE = 1;
     
+    // Set this to true to force plugin results to be encoding as
+    // JS instead of the custom format (useful for benchmarking).
+    private static final boolean FORCE_ENCODE_USING_EVAL = false;
+    
     /**
      * The index into registeredListeners to treat as active. 
      */
@@ -202,7 +206,14 @@ public class NativeToJsMessageQueue {
         if (noResult && keepCallback) {
             return;
         }
-        enqueueMessage(new JsMessage(result, callbackId));
+        JsMessage message = new JsMessage(result, callbackId);
+        if (FORCE_ENCODE_USING_EVAL) {
+            StringBuilder sb = new StringBuilder(message.calculateEncodedLength() + 50);
+            message.encodeAsJsMessage(sb);
+            message = new JsMessage(sb.toString());
+        }
+
+        enqueueMessage(message);
     }
     
     private void enqueueMessage(JsMessage message) {


Mime
View raw message