• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 package org.chromium.mojo_shell_apk;
6 
7 import android.content.Context;
8 
9 import org.chromium.base.JNINamespace;
10 
11 /**
12  * A placeholder class to call native functions.
13  **/
14 @JNINamespace("mojo")
15 public class MojoMain {
16     /**
17      * A guard flag for calling nativeInit() only once.
18      **/
19     private static boolean sInitialized = false;
20 
21     /**
22      * Initializes the native system.
23      **/
ensureInitialized(Context context)24     public static void ensureInitialized(Context context) {
25         if (sInitialized)
26             return;
27         nativeInit(context);
28         sInitialized = true;
29     }
30 
31     /**
32      * Starts the specified application in the specified context.
33      **/
start(Context context, String appUrl)34     public static void start(Context context, String appUrl) {
35         nativeStart(context, appUrl);
36     }
37 
38     /**
39      * Initializes the native system. This API should be called only once per process.
40      **/
nativeInit(Context context)41     private static native void nativeInit(Context context);
nativeStart(Context context, String appUrl)42     private static native void nativeStart(Context context, String appUrl);
43 };
44