Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Side by Side Diff: base/android/auto_jobject.h

Issue 7480016: Add AutoJObject and AutoGlobalJObject (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Updated base.gypi to exclude android directory for any non-Android OS Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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.
14 class AutoJObject {
15 public:
16 // Takes ownership of |obj|.
17 static AutoJObject FromLocalRef(JNIEnv* env, jobject obj);
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698