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

Side by Side Diff: remoting/client/jni/jni_interface.cc

Issue 18612018: Restructure chromoting_jni_instance handling of Java strings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Connection/disconnection state machine and moar comments 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 // This file defines functions that implement the static methods declared in a 5 // This file defines functions that implement the static methods declared in a
6 // closely-related Java class in the platform-specific user interface 6 // closely-related Java class in the platform-specific user interface
7 // implementation. In effect, it is the entry point for all JNI calls *into* 7 // implementation. In effect, it is the entry point for all JNI calls *into*
8 // the C++ codebase from Java. The separate ChromotingJNIInstance class serves 8 // the C++ codebase from Java. The separate ChromotingJNIInstance class serves
9 // as the corresponding exit point, and is responsible for making all JNI calls 9 // as the corresponding exit point, and is responsible for making all JNI calls
10 // *out of* the C++ codebase into Java. 10 // *out of* the C++ codebase into Java.
(...skipping 17 matching lines...) Expand all
28 28
29 JNIEXPORT void JNICALL JNI_IMPLEMENTATION(loadNative)(JNIEnv* env, 29 JNIEXPORT void JNICALL JNI_IMPLEMENTATION(loadNative)(JNIEnv* env,
30 jobject that, 30 jobject that,
31 jobject context) { 31 jobject context) {
32 base::android::ScopedJavaLocalRef<jobject> context_activity(env, context); 32 base::android::ScopedJavaLocalRef<jobject> context_activity(env, context);
33 base::android::InitApplicationContext(context_activity); 33 base::android::InitApplicationContext(context_activity);
34 34
35 remoting::ChromotingJNIInstance::GetInstance(); // Initialize threads now. 35 remoting::ChromotingJNIInstance::GetInstance(); // Initialize threads now.
36 } 36 }
37 37
38 JNIEXPORT void JNICALL JNI_IMPLEMENTATION(connectNative)(JNIEnv* env, 38 JNIEXPORT void JNICALL JNI_IMPLEMENTATION(connectNative)(
39 jobject that, 39 JNIEnv* env,
40 jstring username, 40 jobject that,
41 jstring auth_token, 41 jstring username_jstr,
42 jstring host_jid, 42 jstring auth_token_jstr,
43 jstring host_id, 43 jstring host_jid_jstr,
44 jstring host_pubkey) { 44 jstring host_id_jstr,
45 remoting::ChromotingJNIInstance::GetInstance()->ConnectToHost(username, 45 jstring host_pubkey_jstr) {
46 auth_token, 46 const char* username_cstr = env->GetStringUTFChars(username_jstr, NULL);
47 host_jid, 47 const char* auth_token_cstr = env->GetStringUTFChars(auth_token_jstr, NULL);
48 host_id, 48 const char* host_jid_cstr = env->GetStringUTFChars(host_jid_jstr, NULL);
49 host_pubkey); 49 const char* host_id_cstr = env->GetStringUTFChars(host_id_jstr, NULL);
50 const char* host_pubkey_cstr = env->GetStringUTFChars(host_pubkey_jstr, NULL);
51
52 remoting::ChromotingJNIInstance::GetInstance()->ConnectToHost(
53 username_cstr,
54 auth_token_cstr,
55 host_jid_cstr,
56 host_id_cstr,
57 host_pubkey_cstr);
58
59 env->ReleaseStringUTFChars(username_jstr, username_cstr);
60 env->ReleaseStringUTFChars(auth_token_jstr, auth_token_cstr);
61 env->ReleaseStringUTFChars(host_jid_jstr, host_jid_cstr);
62 env->ReleaseStringUTFChars(host_id_jstr, host_id_cstr);
63 env->ReleaseStringUTFChars(host_pubkey_jstr, host_pubkey_cstr);
50 } 64 }
51 65
52 JNIEXPORT void JNICALL JNI_IMPLEMENTATION(disconnectNative)(JNIEnv* env, 66 JNIEXPORT void JNICALL JNI_IMPLEMENTATION(disconnectNative)(JNIEnv* env,
53 jobject that) { 67 jobject that) {
54 remoting::ChromotingJNIInstance::GetInstance()->DisconnectFromHost(); 68 remoting::ChromotingJNIInstance::GetInstance()->DisconnectFromHost();
55 } 69 }
56 70
57 JNIEXPORT void JNICALL JNI_IMPLEMENTATION(authenticationResponse)(JNIEnv* env, 71 JNIEXPORT void JNICALL JNI_IMPLEMENTATION(authenticationResponse)(
58 jobject that, 72 JNIEnv* env,
59 jstring pin) { 73 jobject that,
60 remoting::ChromotingJNIInstance::GetInstance()->AuthenticateWithPin(pin); 74 jstring pin_jstr) {
75 const char* pin_cstr = env->GetStringUTFChars(pin_jstr, NULL);
76
77 remoting::ChromotingJNIInstance::GetInstance()->AuthenticateWithPin(pin_cstr);
78
79 env->ReleaseStringUTFChars(pin_jstr, pin_cstr);
61 } 80 }
62 81
63 } // extern "C" 82 } // extern "C"
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698