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 |
| 11 #include "base/base_export.h" |
11 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
12 | 13 |
13 namespace base { | 14 namespace base { |
14 namespace android { | 15 namespace android { |
15 | 16 |
16 // Forward declare the generic java reference template class. | 17 // Forward declare the generic java reference template class. |
17 template<typename T> class JavaRef; | 18 template<typename T> class JavaRef; |
18 | 19 |
19 // Template specialization of JavaRef, which acts as the base class for all | 20 // Template specialization of JavaRef, which acts as the base class for all |
20 // other JavaRef<> template types. This allows you to e.g. pass | 21 // other JavaRef<> template types. This allows you to e.g. pass |
21 // ScopedJavaLocalRef<jstring> into a function taking const JavaRef<jobject>& | 22 // ScopedJavaLocalRef<jstring> into a function taking const JavaRef<jobject>& |
22 template<> | 23 template<> |
23 class JavaRef<jobject> { | 24 class BASE_EXPORT JavaRef<jobject> { |
24 public: | 25 public: |
25 jobject obj() const { return obj_; } | 26 jobject obj() const { return obj_; } |
26 | 27 |
27 bool is_null() const { return obj_ == NULL; } | 28 bool is_null() const { return obj_ == NULL; } |
28 | 29 |
29 protected: | 30 protected: |
30 // Initializes a NULL reference. | 31 // Initializes a NULL reference. |
31 JavaRef(); | 32 JavaRef(); |
32 | 33 |
33 // Takes ownership of the |obj| reference passed; requires it to be a local | 34 // Takes ownership of the |obj| reference passed; requires it to be a local |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 // global reference when it is done with it. | 189 // global reference when it is done with it. |
189 T Release() { | 190 T Release() { |
190 return static_cast<T>(this->ReleaseInternal()); | 191 return static_cast<T>(this->ReleaseInternal()); |
191 } | 192 } |
192 }; | 193 }; |
193 | 194 |
194 } // namespace android | 195 } // namespace android |
195 } // namespace base | 196 } // namespace base |
196 | 197 |
197 #endif // BASE_ANDROID_SCOPED_JAVA_REF_H_ | 198 #endif // BASE_ANDROID_SCOPED_JAVA_REF_H_ |
OLD | NEW |