OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.mojo.shell; | 5 package org.chromium.mojo.shell; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 | 8 |
9 import org.chromium.base.JNINamespace; | 9 import org.chromium.base.JNINamespace; |
10 | 10 |
11 import java.io.File; | 11 import java.io.File; |
12 | 12 |
13 /** | 13 /** |
14 * Runnable used to bootstrap execution of Android Mojo application. For the JNI
to work, we need a | 14 * Runnable used to bootstrap execution of Android Mojo application. For the JNI
to work, we need a |
15 * Java class with the application classloader in the call stack. We load this c
lass in the | 15 * Java class with the application classloader in the call stack. We load this c
lass in the |
16 * application classloader and call into native from it to achieve that. | 16 * application classloader and call into native from it to achieve that. |
17 */ | 17 */ |
18 @JNINamespace("mojo::runner") | 18 @JNINamespace("mojo::runner") |
19 public class Bootstrap implements Runnable { | 19 public class Bootstrap implements Runnable { |
20 private final Context mContext; | 20 private final Context mContext; |
21 private final File mBootstrapNativeLibrary; | 21 private final File mBootstrapNativeLibrary; |
22 private final File mApplicationNativeLibrary; | 22 private final File mApplicationNativeLibrary; |
23 private final int mHandle; | 23 private final int mHandle; |
24 private final long mRunApplicationPtr; | 24 private final long mRunApplicationPtr; |
25 private final boolean mIsCachedApp; | |
26 | 25 |
27 public Bootstrap(Context context, File bootstrapNativeLibrary, File applicat
ionNativeLibrary, | 26 public Bootstrap(Context context, File bootstrapNativeLibrary, File applicat
ionNativeLibrary, |
28 Integer handle, Long runApplicationPtr, Boolean isCachedApp) { | 27 Integer handle, Long runApplicationPtr) { |
29 mContext = context; | 28 mContext = context; |
30 mBootstrapNativeLibrary = bootstrapNativeLibrary; | 29 mBootstrapNativeLibrary = bootstrapNativeLibrary; |
31 mApplicationNativeLibrary = applicationNativeLibrary; | 30 mApplicationNativeLibrary = applicationNativeLibrary; |
32 mHandle = handle; | 31 mHandle = handle; |
33 mRunApplicationPtr = runApplicationPtr; | 32 mRunApplicationPtr = runApplicationPtr; |
34 mIsCachedApp = isCachedApp; | |
35 } | 33 } |
36 | 34 |
37 @Override | 35 @Override |
38 public void run() { | 36 public void run() { |
39 System.load(mBootstrapNativeLibrary.getAbsolutePath()); | 37 System.load(mBootstrapNativeLibrary.getAbsolutePath()); |
40 System.load(mApplicationNativeLibrary.getAbsolutePath()); | 38 System.load(mApplicationNativeLibrary.getAbsolutePath()); |
41 nativeBootstrap(mContext, mApplicationNativeLibrary.getAbsolutePath(), m
Handle, | 39 nativeBootstrap(mContext, mApplicationNativeLibrary.getAbsolutePath(), m
Handle, |
42 mRunApplicationPtr, mIsCachedApp); | 40 mRunApplicationPtr); |
43 } | 41 } |
44 | 42 |
45 native void nativeBootstrap(Context context, String libraryPath, int handle, | 43 native void nativeBootstrap(Context context, String libraryPath, int handle, |
46 long runApplicationPtr, boolean isCachedApp); | 44 long runApplicationPtr); |
47 } | 45 } |
OLD | NEW |