| OLD | NEW |
| 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 #include "remoting/client/jni/jni_runtime_delegate.h" | 5 #include "remoting/client/jni/jni_runtime_delegate.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/android/library_loader/library_loader_hooks.h" | 10 #include "base/android/library_loader/library_loader_hooks.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 ConvertJavaStringToUTF8(env, token))); | 61 ConvertJavaStringToUTF8(env, token))); |
| 62 } | 62 } |
| 63 | 63 |
| 64 // JniRuntimeDelegate implementation. | 64 // JniRuntimeDelegate implementation. |
| 65 | 65 |
| 66 // static | 66 // static |
| 67 JniRuntimeDelegate* JniRuntimeDelegate::GetInstance() { | 67 JniRuntimeDelegate* JniRuntimeDelegate::GetInstance() { |
| 68 return base::Singleton<JniRuntimeDelegate>::get(); | 68 return base::Singleton<JniRuntimeDelegate>::get(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 JniRuntimeDelegate::JniRuntimeDelegate() { | 71 JniRuntimeDelegate::JniRuntimeDelegate() : weak_factory_(this) { |
| 72 runtime_ = ChromotingClientRuntime::GetInstance(); | 72 runtime_ = ChromotingClientRuntime::GetInstance(); |
| 73 } | 73 } |
| 74 | 74 |
| 75 JniRuntimeDelegate::~JniRuntimeDelegate() { | 75 JniRuntimeDelegate::~JniRuntimeDelegate() { |
| 76 runtime_ = nullptr; | 76 runtime_ = nullptr; |
| 77 } | 77 } |
| 78 | 78 |
| 79 base::WeakPtr<ChromotingClientRuntime::Delegate> |
| 80 JniRuntimeDelegate::GetWeakPtr() { |
| 81 return weak_factory_.GetWeakPtr(); |
| 82 } |
| 83 |
| 79 void JniRuntimeDelegate::RuntimeWillShutdown() { | 84 void JniRuntimeDelegate::RuntimeWillShutdown() { |
| 80 DCHECK(runtime_->ui_task_runner()->BelongsToCurrentThread()); | 85 DCHECK(runtime_->ui_task_runner()->BelongsToCurrentThread()); |
| 81 | 86 |
| 82 base::WaitableEvent done_event( | 87 base::WaitableEvent done_event( |
| 83 base::WaitableEvent::ResetPolicy::AUTOMATIC, | 88 base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 84 base::WaitableEvent::InitialState::NOT_SIGNALED); | 89 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 85 runtime_->network_task_runner()->PostTask( | 90 runtime_->network_task_runner()->PostTask( |
| 86 FROM_HERE, base::Bind(&JniRuntimeDelegate::DetachFromVmAndSignal, | 91 FROM_HERE, base::Bind(&JniRuntimeDelegate::DetachFromVmAndSignal, |
| 87 base::Unretained(this), &done_event)); | 92 base::Unretained(this), &done_event)); |
| 88 done_event.Wait(); | 93 done_event.Wait(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 109 // TODO(nicholss): I do not like this method name, change it soon. | 114 // TODO(nicholss): I do not like this method name, change it soon. |
| 110 Java_JniInterface_fetchAuthToken(env); | 115 Java_JniInterface_fetchAuthToken(env); |
| 111 } | 116 } |
| 112 | 117 |
| 113 void JniRuntimeDelegate::DetachFromVmAndSignal(base::WaitableEvent* waiter) { | 118 void JniRuntimeDelegate::DetachFromVmAndSignal(base::WaitableEvent* waiter) { |
| 114 base::android::DetachFromVM(); | 119 base::android::DetachFromVM(); |
| 115 waiter->Signal(); | 120 waiter->Signal(); |
| 116 } | 121 } |
| 117 | 122 |
| 118 } // namespace remoting | 123 } // namespace remoting |
| OLD | NEW |