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

Unified Diff: services/android/java/src/org/chromium/services/android/JavaHandler.java

Issue 1464313002: Move //service/android to //service/java_handler (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Follow review Created 5 years, 1 month 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 | « services/android/BUILD.gn ('k') | services/android/java_handler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/android/java/src/org/chromium/services/android/JavaHandler.java
diff --git a/services/android/java/src/org/chromium/services/android/JavaHandler.java b/services/android/java/src/org/chromium/services/android/JavaHandler.java
deleted file mode 100644
index 401762a750f94f810181e80552cdbc1188ccbc80..0000000000000000000000000000000000000000
--- a/services/android/java/src/org/chromium/services/android/JavaHandler.java
+++ /dev/null
@@ -1,86 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package org.chromium.services.android;
-
-import android.content.Context;
-import android.util.Log;
-
-import dalvik.system.DexClassLoader;
-
-import org.chromium.base.CalledByNative;
-import org.chromium.base.JNINamespace;
-import org.chromium.mojo.system.Core;
-import org.chromium.mojo.system.MessagePipeHandle;
-import org.chromium.mojo.system.impl.CoreImpl;
-
-import java.io.File;
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.util.jar.JarFile;
-import java.util.jar.Manifest;
-
-/**
- * Content handler for Android Java code.
- */
-@JNINamespace("services::android")
-public class JavaHandler {
- private static final String TAG = "JavaHandler";
-
- /**
- * Extracts and runs the application libraries contained by the indicated archive.
- *
- * @param context the application context
- * @param archivePath the path of the archive containing the application to be run
- * @param cachePath the path to a directory that can be used to save cached data.
- * @param applicationRequestHandle handle to the shell to be passed to the native application.
- * On the Java side this is opaque payload.
- */
- @CalledByNative
- private static boolean bootstrap(Context context, String archivePath,
- String cachePath, int applicationRequestHandle) {
- File application_java_library = new File(archivePath);
-
- String dexPath = application_java_library.getAbsolutePath();
- DexClassLoader bootstrapLoader = new DexClassLoader(dexPath,
- cachePath, null, JavaHandler.class.getClassLoader());
-
- // The starting Mojo class is a class implementing a static MojoMain method. Its name is
- // defined in the .jar manifest file, like a .jar defines a Main-Class attribute for the
- // starting point of a standalone java application.
- String mojoClass;
- try (JarFile jar = new JarFile(application_java_library)) {
- Manifest manifest = jar.getManifest();
- mojoClass = manifest.getMainAttributes().getValue("Mojo-Class");
- } catch (IOException e) {
- Log.e(TAG, "Unable to extract Manifest attributes", e);
- return false;
- }
-
- if (mojoClass == null) {
- Log.e(TAG, "Mojo-Class class not found");
- return false;
- }
-
- Core core = CoreImpl.getInstance();
- try (MessagePipeHandle handle = core.acquireNativeHandle(
- applicationRequestHandle).toMessagePipeHandle()) {
- Class<?> loadedClass = bootstrapLoader.loadClass(mojoClass);
- Method mojoMain =
- loadedClass.getMethod("mojoMain", Context.class, Core.class,
- MessagePipeHandle.class);
- nativePreInvokeEvent();
- mojoMain.invoke(null, context, core, handle);
- } catch (Throwable t) {
- Log.e(TAG, "Running MojoMain failed.", t);
- return false;
- }
- return true;
- }
-
- /**
- * Notify the native side before starting the handled application for tracing.
- */
- private static native void nativePreInvokeEvent();
-}
« no previous file with comments | « services/android/BUILD.gn ('k') | services/android/java_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698