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); | |
brettw
2011/08/01 16:03:54
There's not a defined place for this in the header
steveblock
2011/08/02 15:05:46
Done.
| |
21 | |
22 AutoGlobalJObject(); | |
23 AutoGlobalJObject(const AutoGlobalJObject& other); | |
brettw
2011/08/01 16:03:54
Do you need an implicit copy constructor? These ar
steveblock
2011/08/02 15:05:46
We don't need one for AutoGlobalJObject (other tha
brettw
2011/08/02 15:55:39
If you're going to be returning these by value, it
| |
24 explicit AutoGlobalJObject(const AutoJObject& obj); | |
25 ~AutoGlobalJObject(); | |
26 | |
27 void Reset(); | |
28 void Reset(const AutoGlobalJObject& other); | |
29 jobject obj() const; | |
brettw
2011/08/01 16:03:54
This should be inline. If it can't be, it should b
steveblock
2011/08/02 15:05:46
Done.
| |
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 |