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_JOBJECT_H_ | |
| 6 #define BASE_ANDROID_AUTO_JOBJECT_H_ | |
| 7 | |
| 8 #include <jni.h> | |
| 9 | |
| 10 namespace base { | |
| 11 namespace android { | |
| 12 | |
| 13 // A helper class that automatically deletes the local reference to the jobject. | |
|
brettw
2011/08/01 16:03:54
Basically the same comments from the other class.
| |
| 14 class AutoJObject { | |
| 15 public: | |
| 16 // Takes ownership of |obj|. | |
| 17 static AutoJObject FromLocalRef(JNIEnv* env, jobject obj); | |
|
steveblock
2011/08/02 15:05:46
We could simplify the API by removing this method
bulach
2011/08/02 15:18:36
no particular preference, happy to go with the sim
Sami (do not use)
2011/08/02 15:23:49
I'd be fine with having a new constructor for Auto
| |
| 18 | |
| 19 AutoJObject(const AutoJObject& other); | |
| 20 ~AutoJObject(); | |
| 21 | |
| 22 JNIEnv* env() const; | |
| 23 jobject obj() const; | |
| 24 // Releases the local reference to the caller. The caller *must* delete the | |
| 25 // local reference when it is done with it. | |
| 26 jobject Release(); | |
| 27 | |
| 28 private: | |
| 29 AutoJObject(); // Not permitted. | |
| 30 AutoJObject(JNIEnv* env, jobject obj); | |
| 31 | |
| 32 JNIEnv* env_; | |
| 33 jobject obj_; | |
| 34 }; | |
| 35 | |
| 36 } // namespace android | |
| 37 } // namespace base | |
| 38 | |
| 39 #endif // BASE_ANDROID_AUTO_JOBJECT_H_ | |
| OLD | NEW |