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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include "remoting/host/android/jni_host.h" 5 #include "remoting/host/android/jni_host.h"
6 6
7 #include "base/android/jni_string.h" 7 #include "base/android/jni_string.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "jni/Host_jni.h" 10 #include "jni/Host_jni.h"
11 #include "net/base/url_util.h" 11 #include "net/base/url_util.h"
12 #include "net/socket/ssl_server_socket.h" 12 #include "net/socket/ssl_server_socket.h"
13 #include "remoting/base/auto_thread_task_runner.h" 13 #include "remoting/base/auto_thread_task_runner.h"
14 #include "remoting/base/logging.h" 14 #include "remoting/base/logging.h"
15 #include "remoting/host/chromoting_host_context.h" 15 #include "remoting/host/chromoting_host_context.h"
16 #include "remoting/host/it2me/it2me_host.h" 16 #include "remoting/host/it2me/it2me_host.h"
17 #include "remoting/host/service_urls.h" 17 #include "remoting/host/service_urls.h"
18 #include "remoting/signaling/xmpp_signal_strategy.h" 18 #include "remoting/signaling/xmpp_signal_strategy.h"
19 19
20 using base::android::ConvertJavaStringToUTF8; 20 using base::android::ConvertJavaStringToUTF8;
21 using base::android::ConvertUTF8ToJavaString;
21 22
22 namespace remoting { 23 namespace remoting {
23 24
24 JniHost::JniHost() : weak_factory_(this) { 25 JniHost::JniHost(JNIEnv* env, jobject java_host) : weak_factory_(this) {
26 java_host_.Reset(env, java_host);
25 weak_ptr_ = weak_factory_.GetWeakPtr(); 27 weak_ptr_ = weak_factory_.GetWeakPtr();
26 28
27 base::CommandLine::Init(0, nullptr); 29 base::CommandLine::Init(0, nullptr);
28 30
29 // Enable support for SSL server sockets, which must be done while still 31 // Enable support for SSL server sockets, which must be done while still
30 // single-threaded. 32 // single-threaded.
31 net::EnableSSLServerSockets(); 33 net::EnableSSLServerSockets();
32 34
33 if (!base::MessageLoop::current()) { 35 if (!base::MessageLoop::current()) {
34 HOST_LOG << "Starting main message loop"; 36 HOST_LOG << "Starting main message loop";
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 93
92 void JniHost::Disconnect(JNIEnv* env, 94 void JniHost::Disconnect(JNIEnv* env,
93 const base::android::JavaParamRef<jobject>& caller) {} 95 const base::android::JavaParamRef<jobject>& caller) {}
94 96
95 void JniHost::OnClientAuthenticated(const std::string& client_username) { 97 void JniHost::OnClientAuthenticated(const std::string& client_username) {
96 HOST_LOG << "OnClientAuthenticated: " << client_username; 98 HOST_LOG << "OnClientAuthenticated: " << client_username;
97 } 99 }
98 100
99 void JniHost::OnStoreAccessCode(const std::string& access_code, 101 void JniHost::OnStoreAccessCode(const std::string& access_code,
100 base::TimeDelta access_code_lifetime) { 102 base::TimeDelta access_code_lifetime) {
101 HOST_LOG << "OnStoreAccessCode: " << access_code << ", " 103 JNIEnv* env = base::android::AttachCurrentThread();
102 << access_code_lifetime.InSeconds(); 104 Java_Host_onAccessCodeReceived(
105 env, java_host_.obj(), ConvertUTF8ToJavaString(env, access_code).obj(),
106 static_cast<int>(access_code_lifetime.InSeconds()));
103 } 107 }
104 108
105 void JniHost::OnNatPolicyChanged(bool nat_traversal_enabled) { 109 void JniHost::OnNatPolicyChanged(bool nat_traversal_enabled) {
106 HOST_LOG << "OnNatPolicyChanged: " << nat_traversal_enabled; 110 HOST_LOG << "OnNatPolicyChanged: " << nat_traversal_enabled;
107 } 111 }
108 112
109 void JniHost::OnStateChanged(It2MeHostState state, 113 void JniHost::OnStateChanged(It2MeHostState state,
110 const std::string& error_message) { 114 const std::string& error_message) {
111 HOST_LOG << "OnStateChanged: " << state; 115 JNIEnv* env = base::android::AttachCurrentThread();
116 Java_Host_onStateChanged(env, java_host_.obj(), state,
117 ConvertUTF8ToJavaString(env, error_message).obj());
112 } 118 }
113 119
114 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& caller) { 120 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& caller) {
115 return reinterpret_cast<intptr_t>(new JniHost()); 121 return reinterpret_cast<intptr_t>(new JniHost(env, caller));
116 } 122 }
117 123
118 } // namespace remoting 124 } // namespace remoting
OLDNEW
« 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