Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1291)

Unified Diff: mojo/shell/android/apk/src/org/chromium/mojo_shell_apk/MojoMain.java

Issue 249713006: Mojo: Fix crash on MojoShell on Android (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated to ToT. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | mojo/shell/android/apk/src/org/chromium/mojo_shell_apk/MojoShellActivity.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
};
« no previous file with comments | « no previous file | mojo/shell/android/apk/src/org/chromium/mojo_shell_apk/MojoShellActivity.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698