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

Unified Diff: remoting/android/host/src/org/chromium/chromoting/host/jni/Host.java

Issue 1867433002: [remoting android] Add native library and JNI glue for host. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
Index: remoting/android/host/src/org/chromium/chromoting/host/jni/Host.java
diff --git a/remoting/android/host/src/org/chromium/chromoting/host/jni/Host.java b/remoting/android/host/src/org/chromium/chromoting/host/jni/Host.java
new file mode 100644
index 0000000000000000000000000000000000000000..a85adcd487f2ee243ed0cc2613d340f12217eecc
--- /dev/null
+++ b/remoting/android/host/src/org/chromium/chromoting/host/jni/Host.java
@@ -0,0 +1,44 @@
+// Copyright 2016 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.chromoting.host.jni;
+
+import android.content.Context;
+
+import org.chromium.base.ContextUtils;
+import org.chromium.base.annotations.JNINamespace;
+
+/**
+ * Class to allow Java code to access the native C++ implementation of the Host process. This class
+ * controls the lifetime of the corresponding C++ object.
+ */
+@JNINamespace("remoting")
+public class Host {
+ // Pointer to the C++ object, cast to a |long|.
+ private long mNativeJniHost;
+
+ private static boolean sLoaded;
+
+ // Called once from the main Activity. Loads and initializes the native
+ // code.
+ public static void loadLibrary(Context context) {
+ if (sLoaded) return;
Sergey Ulanov 2016/04/07 00:41:06 Do we need synchronization here? Or if we don't ex
Lambros 2016/04/11 18:44:47 It's only called during Activity.onCreate() on the
+
+ System.loadLibrary("remoting_host_jni");
+ ContextUtils.initApplicationContext(context.getApplicationContext());
+ sLoaded = true;
+ }
+
+ public Host() {
+ mNativeJniHost = nativeInit();
+ }
+
+ private native long nativeInit();
+
+ public void destroy() {
+ nativeDestroy(mNativeJniHost);
+ }
+
+ private native void nativeDestroy(long nativeJniHost);
+}
« no previous file with comments | « remoting/android/host/src/org/chromium/chromoting/host/MainActivity.java ('k') | remoting/host/android/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698