| OLD | NEW |
| 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/client/jni/jni_client.h" | 5 #include "remoting/client/jni/jni_client.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "jni/Client_jni.h" | 10 #include "jni/Client_jni.h" |
| 11 #include "remoting/client/jni/chromoting_jni_instance.h" | 11 #include "remoting/client/jni/chromoting_jni_instance.h" |
| 12 #include "remoting/client/jni/chromoting_jni_runtime.h" | 12 #include "remoting/client/jni/chromoting_jni_runtime.h" |
| 13 #include "remoting/client/jni/display_updater_factory.h" | 13 #include "remoting/client/jni/display_updater_factory.h" |
| 14 #include "remoting/client/jni/jni_display_handler.h" | 14 #include "remoting/client/jni/jni_display_handler.h" |
| 15 #include "remoting/client/jni/jni_gl_display_handler.h" | 15 #include "remoting/client/jni/jni_gl_display_handler.h" |
| 16 #include "remoting/client/jni/jni_pairing_secret_fetcher.h" | 16 #include "remoting/client/jni/jni_pairing_secret_fetcher.h" |
| 17 #include "remoting/client/jni/jni_touch_event_data.h" | 17 #include "remoting/client/jni/jni_touch_event_data.h" |
| 18 #include "remoting/client/jni/jni_video_renderer.h" | 18 #include "remoting/client/jni/jni_video_renderer.h" |
| 19 | 19 |
| 20 using base::android::ConvertJavaStringToUTF8; | 20 using base::android::ConvertJavaStringToUTF8; |
| 21 using base::android::ConvertUTF8ToJavaString; | 21 using base::android::ConvertUTF8ToJavaString; |
| 22 | 22 |
| 23 namespace remoting { | 23 namespace remoting { |
| 24 | 24 |
| 25 JniClient::JniClient(ChromotingJniRuntime* runtime, | 25 JniClient::JniClient(ChromotingJniRuntime* runtime, |
| 26 base::android::ScopedJavaGlobalRef<jobject> java_client) | 26 base::android::ScopedJavaGlobalRef<jobject> java_client) |
| 27 : runtime_(runtime), | 27 : runtime_(runtime), |
| 28 java_client_(java_client), | 28 java_client_(java_client), |
| 29 weak_factory_(this) {} | 29 weak_factory_(this) { |
| 30 weak_ptr_ = weak_factory_.GetWeakPtr(); |
| 31 } |
| 30 | 32 |
| 31 JniClient::~JniClient() { | 33 JniClient::~JniClient() { |
| 32 DCHECK(runtime_->ui_task_runner()->BelongsToCurrentThread()); | 34 DCHECK(runtime_->ui_task_runner()->BelongsToCurrentThread()); |
| 33 | 35 |
| 34 // The session must be shut down first, since it depends on our other | 36 // The session must be shut down first, since it depends on our other |
| 35 // components' still being alive. | 37 // components' still being alive. |
| 36 DisconnectFromHost(); | 38 DisconnectFromHost(); |
| 37 } | 39 } |
| 38 | 40 |
| 39 void JniClient::ConnectToHost(DisplayUpdaterFactory* updater_factory, | 41 void JniClient::ConnectToHost(DisplayUpdaterFactory* updater_factory, |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 const JavaParamRef<jstring>& data) { | 290 const JavaParamRef<jstring>& data) { |
| 289 session_->SendClientMessage(ConvertJavaStringToUTF8(env, type), | 291 session_->SendClientMessage(ConvertJavaStringToUTF8(env, type), |
| 290 ConvertJavaStringToUTF8(env, data)); | 292 ConvertJavaStringToUTF8(env, data)); |
| 291 } | 293 } |
| 292 | 294 |
| 293 void JniClient::Destroy(JNIEnv* env, const JavaParamRef<jobject>& caller) { | 295 void JniClient::Destroy(JNIEnv* env, const JavaParamRef<jobject>& caller) { |
| 294 delete this; | 296 delete this; |
| 295 } | 297 } |
| 296 | 298 |
| 297 base::WeakPtr<JniClient> JniClient::GetWeakPtr() { | 299 base::WeakPtr<JniClient> JniClient::GetWeakPtr() { |
| 298 return weak_factory_.GetWeakPtr(); | 300 return weak_ptr_; |
| 299 } | 301 } |
| 300 | 302 |
| 301 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& caller) { | 303 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& caller) { |
| 302 return reinterpret_cast<intptr_t>( | 304 return reinterpret_cast<intptr_t>( |
| 303 new JniClient(ChromotingJniRuntime::GetInstance(), | 305 new JniClient(ChromotingJniRuntime::GetInstance(), |
| 304 base::android::ScopedJavaGlobalRef<jobject>(env, caller))); | 306 base::android::ScopedJavaGlobalRef<jobject>(env, caller))); |
| 305 } | 307 } |
| 306 | 308 |
| 307 } // namespace remoting | 309 } // namespace remoting |
| OLD | NEW |