| 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 10 matching lines...) Expand all Loading... |
| 21 namespace mojo { | 21 namespace mojo { |
| 22 namespace android { | 22 namespace android { |
| 23 | 23 |
| 24 using base::android::JavaParamRef; | 24 using base::android::JavaParamRef; |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 class WatcherWithMessageLoopObserver | 28 class WatcherWithMessageLoopObserver |
| 29 : public base::MessageLoop::DestructionObserver { | 29 : public base::MessageLoop::DestructionObserver { |
| 30 public: | 30 public: |
| 31 WatcherWithMessageLoopObserver() {} | 31 WatcherWithMessageLoopObserver() : watcher_(FROM_HERE) {} |
| 32 | 32 |
| 33 ~WatcherWithMessageLoopObserver() override { StopObservingIfNecessary(); } | 33 ~WatcherWithMessageLoopObserver() override { StopObservingIfNecessary(); } |
| 34 | 34 |
| 35 jint Start(JNIEnv* env, | 35 jint Start(JNIEnv* env, |
| 36 const JavaParamRef<jobject>& jcaller, | 36 const JavaParamRef<jobject>& jcaller, |
| 37 jint mojo_handle, | 37 jint mojo_handle, |
| 38 jint signals) { | 38 jint signals) { |
| 39 if (!is_observing_) { | 39 if (!is_observing_) { |
| 40 is_observing_ = true; | 40 is_observing_ = true; |
| 41 base::MessageLoop::current()->AddDestructionObserver(this); | 41 base::MessageLoop::current()->AddDestructionObserver(this); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 jlong watcher_ptr) { | 126 jlong watcher_ptr) { |
| 127 delete reinterpret_cast<WatcherWithMessageLoopObserver*>(watcher_ptr); | 127 delete reinterpret_cast<WatcherWithMessageLoopObserver*>(watcher_ptr); |
| 128 } | 128 } |
| 129 | 129 |
| 130 bool RegisterWatcherImpl(JNIEnv* env) { | 130 bool RegisterWatcherImpl(JNIEnv* env) { |
| 131 return RegisterNativesImpl(env); | 131 return RegisterNativesImpl(env); |
| 132 } | 132 } |
| 133 | 133 |
| 134 } // namespace android | 134 } // namespace android |
| 135 } // namespace mojo | 135 } // namespace mojo |
| OLD | NEW |