| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef BASE_ANDROID_SCOPED_JAVA_REF_H_ | 5 #ifndef BASE_ANDROID_SCOPED_JAVA_REF_H_ |
| 6 #define BASE_ANDROID_SCOPED_JAVA_REF_H_ | 6 #define BASE_ANDROID_SCOPED_JAVA_REF_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 | 10 |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 // imposed by the underlying Java object that it references). | 171 // imposed by the underlying Java object that it references). |
| 172 template<typename T> | 172 template<typename T> |
| 173 class ScopedJavaGlobalRef : public JavaRef<T> { | 173 class ScopedJavaGlobalRef : public JavaRef<T> { |
| 174 public: | 174 public: |
| 175 ScopedJavaGlobalRef() {} | 175 ScopedJavaGlobalRef() {} |
| 176 | 176 |
| 177 explicit ScopedJavaGlobalRef(const ScopedJavaGlobalRef<T>& other) { | 177 explicit ScopedJavaGlobalRef(const ScopedJavaGlobalRef<T>& other) { |
| 178 this->Reset(other); | 178 this->Reset(other); |
| 179 } | 179 } |
| 180 | 180 |
| 181 ScopedJavaGlobalRef(JNIEnv* env, T obj) { this->Reset(env, obj); } |
| 182 |
| 181 template<typename U> | 183 template<typename U> |
| 182 explicit ScopedJavaGlobalRef(const U& other) { | 184 explicit ScopedJavaGlobalRef(const U& other) { |
| 183 this->Reset(other); | 185 this->Reset(other); |
| 184 } | 186 } |
| 185 | 187 |
| 186 ~ScopedJavaGlobalRef() { | 188 ~ScopedJavaGlobalRef() { |
| 187 this->Reset(); | 189 this->Reset(); |
| 188 } | 190 } |
| 189 | 191 |
| 190 void Reset() { | 192 void Reset() { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 206 // global reference when it is done with it. | 208 // global reference when it is done with it. |
| 207 T Release() { | 209 T Release() { |
| 208 return static_cast<T>(this->ReleaseInternal()); | 210 return static_cast<T>(this->ReleaseInternal()); |
| 209 } | 211 } |
| 210 }; | 212 }; |
| 211 | 213 |
| 212 } // namespace android | 214 } // namespace android |
| 213 } // namespace base | 215 } // namespace base |
| 214 | 216 |
| 215 #endif // BASE_ANDROID_SCOPED_JAVA_REF_H_ | 217 #endif // BASE_ANDROID_SCOPED_JAVA_REF_H_ |
| OLD | NEW |