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

Unified Diff: remoting/host/android/jni_host.cc

Issue 1884253003: [remoting android] Plumb It2Me events from C++ to Java (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@android-host-it2me-connect
Patch Set: Address comments, git cl format 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
« no previous file with comments | « remoting/host/android/jni_host.h ('k') | remoting/host/it2me/it2me_host.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/android/jni_host.cc
diff --git a/remoting/host/android/jni_host.cc b/remoting/host/android/jni_host.cc
index d45d4293f64ea84be41a71894ec3eddd228d187d..f6ae73cd911f3a66c2bcda4db2a138bfb50a46e6 100644
--- a/remoting/host/android/jni_host.cc
+++ b/remoting/host/android/jni_host.cc
@@ -18,10 +18,12 @@
#include "remoting/signaling/xmpp_signal_strategy.h"
using base::android::ConvertJavaStringToUTF8;
+using base::android::ConvertUTF8ToJavaString;
namespace remoting {
-JniHost::JniHost() : weak_factory_(this) {
+JniHost::JniHost(JNIEnv* env, jobject java_host) : weak_factory_(this) {
+ java_host_.Reset(env, java_host);
weak_ptr_ = weak_factory_.GetWeakPtr();
base::CommandLine::Init(0, nullptr);
@@ -98,8 +100,10 @@ void JniHost::OnClientAuthenticated(const std::string& client_username) {
void JniHost::OnStoreAccessCode(const std::string& access_code,
base::TimeDelta access_code_lifetime) {
- HOST_LOG << "OnStoreAccessCode: " << access_code << ", "
- << access_code_lifetime.InSeconds();
+ JNIEnv* env = base::android::AttachCurrentThread();
+ Java_Host_onAccessCodeReceived(
+ env, java_host_.obj(), ConvertUTF8ToJavaString(env, access_code).obj(),
+ static_cast<int>(access_code_lifetime.InSeconds()));
}
void JniHost::OnNatPolicyChanged(bool nat_traversal_enabled) {
@@ -108,11 +112,13 @@ void JniHost::OnNatPolicyChanged(bool nat_traversal_enabled) {
void JniHost::OnStateChanged(It2MeHostState state,
const std::string& error_message) {
- HOST_LOG << "OnStateChanged: " << state;
+ JNIEnv* env = base::android::AttachCurrentThread();
+ Java_Host_onStateChanged(env, java_host_.obj(), state,
+ ConvertUTF8ToJavaString(env, error_message).obj());
}
static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& caller) {
- return reinterpret_cast<intptr_t>(new JniHost());
+ return reinterpret_cast<intptr_t>(new JniHost(env, caller));
}
} // namespace remoting
« no previous file with comments | « remoting/host/android/jni_host.h ('k') | remoting/host/it2me/it2me_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698