Chromium Code Reviews| 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 #include "base/basictypes.h" | |
| 12 | |
| 13 namespace base { | |
| 14 namespace android { | |
| 15 | |
| 16 // Holds a global reference to a Java object. The global reference is scoped | |
| 17 // to the lifetime of this object. | |
| 18 class AutoGlobalJObject { | |
| 19 public: | |
| 20 // Holds a NULL reference. | |
| 21 AutoGlobalJObject(); | |
| 22 // Takes a new global reference to the Java object held by obj. The global | |
| 23 // reference is deleted when this object goes out of scope. | |
| 24 explicit AutoGlobalJObject(const AutoJObject& obj); | |
| 25 ~AutoGlobalJObject(); | |
| 26 | |
| 27 void Reset(); | |
| 28 void Reset(const AutoGlobalJObject& other); | |
| 29 inline jobject obj() const { return obj_; } | |
| 30 | |
| 31 private: | |
| 32 DISALLOW_COPY_AND_ASSIGN(AutoGlobalJObject); | |
|
brettw
2011/08/02 15:55:39
This should be last.
| |
| 33 | |
| 34 JNIEnv* env_; | |
| 35 jobject obj_; | |
| 36 }; | |
| 37 | |
| 38 } // namespace android | |
| 39 } // namespace base | |
| 40 | |
| 41 #endif // BASE_ANDROID_AUTO_GLOBAL_JOBJECT_H_ | |
| OLD | NEW |