| 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 "mojo/android/system/watcher_impl.h" | 5 #include "mojo/android/system/watcher_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/android/base_jni_registrar.h" | 10 #include "base/android/base_jni_registrar.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 class JavaWatcherCallback { | 27 class JavaWatcherCallback { |
| 28 public: | 28 public: |
| 29 JavaWatcherCallback(JNIEnv* env, const JavaParamRef<jobject>& java_watcher) { | 29 JavaWatcherCallback(JNIEnv* env, const JavaParamRef<jobject>& java_watcher) { |
| 30 java_watcher_.Reset(env, java_watcher); | 30 java_watcher_.Reset(env, java_watcher); |
| 31 } | 31 } |
| 32 | 32 |
| 33 void OnHandleReady(MojoResult result) { | 33 void OnHandleReady(MojoResult result) { |
| 34 Java_WatcherImpl_onHandleReady(base::android::AttachCurrentThread(), | 34 Java_WatcherImpl_onHandleReady(base::android::AttachCurrentThread(), |
| 35 java_watcher_.obj(), result); | 35 java_watcher_, result); |
| 36 } | 36 } |
| 37 | 37 |
| 38 private: | 38 private: |
| 39 base::android::ScopedJavaGlobalRef<jobject> java_watcher_; | 39 base::android::ScopedJavaGlobalRef<jobject> java_watcher_; |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 } // namespace | 42 } // namespace |
| 43 | 43 |
| 44 static jlong CreateWatcher(JNIEnv* env, const JavaParamRef<jobject>& jcaller) { | 44 static jlong CreateWatcher(JNIEnv* env, const JavaParamRef<jobject>& jcaller) { |
| 45 return reinterpret_cast<jlong>(new Watcher); | 45 return reinterpret_cast<jlong>(new Watcher); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 69 jlong watcher_ptr) { | 69 jlong watcher_ptr) { |
| 70 delete reinterpret_cast<Watcher*>(watcher_ptr); | 70 delete reinterpret_cast<Watcher*>(watcher_ptr); |
| 71 } | 71 } |
| 72 | 72 |
| 73 bool RegisterWatcherImpl(JNIEnv* env) { | 73 bool RegisterWatcherImpl(JNIEnv* env) { |
| 74 return RegisterNativesImpl(env); | 74 return RegisterNativesImpl(env); |
| 75 } | 75 } |
| 76 | 76 |
| 77 } // namespace android | 77 } // namespace android |
| 78 } // namespace mojo | 78 } // namespace mojo |
| OLD | NEW |