Index: mojo/shell/android/apk/src/org/chromium/mojo_shell_apk/MojoMain.java |
diff --git a/mojo/shell/android/apk/src/org/chromium/mojo_shell_apk/MojoMain.java b/mojo/shell/android/apk/src/org/chromium/mojo_shell_apk/MojoMain.java |
index 364f4d39f34ba983c5ad03fdcf8b86ddff0f5368..55fa0becaf0dba08af19c06b20ff78ed7dba9691 100644 |
--- a/mojo/shell/android/apk/src/org/chromium/mojo_shell_apk/MojoMain.java |
+++ b/mojo/shell/android/apk/src/org/chromium/mojo_shell_apk/MojoMain.java |
@@ -8,13 +8,24 @@ import android.content.Context; |
import org.chromium.base.JNINamespace; |
+/** |
+ * A placeholder class to call native functions. |
+ **/ |
@JNINamespace("mojo") |
public class MojoMain { |
/** |
+ * A guard flag for calling nativeInit() only once. |
+ **/ |
+ private static boolean sInitialized = false; |
+ |
+ /** |
* Initializes the native system. |
**/ |
- public static void init(Context context) { |
+ public static void ensureInitialized(Context context) { |
+ if (sInitialized) |
+ return; |
nativeInit(context); |
+ sInitialized = true; |
} |
/** |
@@ -24,6 +35,9 @@ public class MojoMain { |
nativeStart(context, appUrl); |
} |
+ /** |
+ * Initializes the native system. This API should be called only once per process. |
+ **/ |
private static native void nativeInit(Context context); |
private static native void nativeStart(Context context, String appUrl); |
}; |