OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef BASE_ANDROID_AUTO_GLOBAL_JOBJECT_H_ |
| 6 #define BASE_ANDROID_AUTO_GLOBAL_JOBJECT_H_ |
| 7 |
| 8 #include <jni.h> |
| 9 |
| 10 #include "base/android/auto_jobject.h" |
| 11 |
| 12 namespace base { |
| 13 namespace android { |
| 14 |
| 15 // A global reference to a Java object which is cleaned up automatically when |
| 16 // this object gets deleted. |
| 17 class AutoGlobalJObject { |
| 18 public: |
| 19 // Takes ownership of |obj|. |
| 20 static AutoGlobalJObject FromLocalRef(JNIEnv* env, jobject obj); |
| 21 |
| 22 AutoGlobalJObject(); |
| 23 AutoGlobalJObject(const AutoGlobalJObject& other); |
| 24 explicit AutoGlobalJObject(const AutoJObject& obj); |
| 25 ~AutoGlobalJObject(); |
| 26 |
| 27 void Reset(); |
| 28 void Reset(const AutoGlobalJObject& other); |
| 29 jobject obj() const; |
| 30 |
| 31 private: |
| 32 // Not permitted. |
| 33 AutoGlobalJObject& operator=(const AutoGlobalJObject& other); |
| 34 |
| 35 JNIEnv* env_; |
| 36 jobject obj_; |
| 37 }; |
| 38 |
| 39 } // namespace android |
| 40 } // namespace base |
| 41 |
| 42 #endif // BASE_ANDROID_AUTO_GLOBAL_JOBJECT_H_ |
OLD | NEW |