| 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") | 18 @JNINamespace("mojo::shell") |
| 19 public class Bootstrap implements Runnable { | 19 public class Bootstrap implements Runnable { |
| 20 | |
| 21 private final Context mContext; | 20 private final Context mContext; |
| 22 private final File mBootstrapNativeLibrary; | 21 private final File mBootstrapNativeLibrary; |
| 23 private final File mApplicationNativeLibrary; | 22 private final File mApplicationNativeLibrary; |
| 24 private final int mHandle; | 23 private final int mHandle; |
| 25 private final long mRunApplicationPtr; | 24 private final long mRunApplicationPtr; |
| 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) { | 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 } | 33 } |
| 35 | 34 |
| 36 @Override | 35 @Override |
| 37 public void run() { | 36 public void run() { |
| 38 System.load(mBootstrapNativeLibrary.getAbsolutePath()); | 37 System.load(mBootstrapNativeLibrary.getAbsolutePath()); |
| 39 System.load(mApplicationNativeLibrary.getAbsolutePath()); | 38 System.load(mApplicationNativeLibrary.getAbsolutePath()); |
| 40 nativeBootstrap(mContext, mApplicationNativeLibrary.getAbsolutePath(), m
Handle, | 39 nativeBootstrap(mContext, mApplicationNativeLibrary.getAbsolutePath(), m
Handle, |
| 41 mRunApplicationPtr); | 40 mRunApplicationPtr); |
| 42 } | 41 } |
| 43 | 42 |
| 44 native void nativeBootstrap(Context context, String libraryPath, int handle, | 43 native void nativeBootstrap(Context context, String libraryPath, int handle, |
| 45 long runApplicationPtr); | 44 long runApplicationPtr); |
| 46 } | 45 } |
| OLD | NEW |