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

Unified Diff: remoting/client/jni/jni_interface.cc

Issue 18856012: Create new remoting_client_jni target (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Gary's recommendations Created 7 years, 5 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/client/jni/jni_interface.cc
diff --git a/remoting/client/jni/jni_interface.cc b/remoting/client/jni/jni_interface.cc
new file mode 100644
index 0000000000000000000000000000000000000000..cb7f6c261066328bc9d6ff119a1519e1bd2e6e8f
--- /dev/null
+++ b/remoting/client/jni/jni_interface.cc
@@ -0,0 +1,57 @@
+// Copyright 2013 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.
+
+// This file defines functions that implement the static methods declared in a
+// closely-related Java class in the platform-specific user interface
+// implementation. In effect, it is the entry point for all JNI calls *into*
+// the C++ codebase from Java. The separate ChromotingJNIInstance class serves
+// as the corresponding exit point, and is responsible for making all JNI calls
+// *out of* the C++ codebase into Java.
+
+#include <jni.h>
+
+#include "base/android/jni_android.h"
+#include "base/memory/ref_counted.h"
+#include "remoting/client/jni/chromoting_jni_instance.h"
+
+// Class and package name of the Java class that declares this file's functions.
+#define JNI_IMPLEMENTATION(method) \
+ Java_org_chromium_chromoting_jni_JNIInterface_##method
+
+extern "C" {
+
+JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
+ base::android::InitVM(vm);
+ return JNI_VERSION_1_2;
+}
+
+JNIEXPORT void JNICALL JNI_IMPLEMENTATION(loadNative)(JNIEnv* env,
+ jobject that,
+ jobject context) {
+ base::android::ScopedJavaLocalRef<jobject> context_activity(env, context);
+ base::android::InitApplicationContext(context_activity);
+
+ remoting::ChromotingJNIInstance::GetInstance(); // Initialize threads now.
+}
+
+JNIEXPORT void JNICALL JNI_IMPLEMENTATION(connectNative)(JNIEnv* env,
+ jobject that,
+ jstring username,
+ jstring auth_token,
+ jstring host_jid,
+ jstring host_id,
+ jstring host_pubkey) {
+ remoting::ChromotingJNIInstance::GetInstance()->ConnectToHost(username,
+ auth_token,
+ host_jid,
+ host_id,
+ host_pubkey);
+}
+
+JNIEXPORT void JNICALL JNI_IMPLEMENTATION(disconnectNative)(JNIEnv* env,
+ jobject that) {
+ remoting::ChromotingJNIInstance::GetInstance()->DisconnectFromHost();
+}
+
+} // extern "C"

Powered by Google App Engine
This is Rietveld 408576698