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 #include "base/android/auto_jobject.h" | |
6 | |
7 #include <stddef.h> | |
8 | |
9 namespace base { | |
10 namespace android { | |
11 | |
12 AutoJObject AutoJObject::FromLocalRef(JNIEnv* env, jobject obj) { | |
13 return AutoJObject(env, obj); | |
14 } | |
15 | |
16 AutoJObject::AutoJObject(const AutoJObject& other) | |
17 : env_(other.env_), | |
18 obj_(other.obj_ ? other.env_->NewLocalRef(other.obj_) : NULL) { | |
19 } | |
20 | |
21 AutoJObject::AutoJObject(JNIEnv* env, jobject obj) | |
22 : env_(env), | |
23 obj_(obj) { | |
24 } | |
25 | |
26 AutoJObject::~AutoJObject() { | |
27 if (obj_) | |
28 env_->DeleteLocalRef(obj_); | |
29 } | |
30 | |
31 JNIEnv* AutoJObject::env() const { | |
32 return env_; | |
33 } | |
34 | |
35 jobject AutoJObject::obj() const { | |
36 return obj_; | |
37 } | |
38 | |
39 jobject AutoJObject::Release() { | |
40 jobject obj = obj_; | |
41 obj_ = 0; | |
bulach
2011/07/26 18:23:04
nit: NULL
| |
42 return obj; | |
43 } | |
44 | |
45 } // namespace android | |
46 } // namespace base | |
47 | |
bulach
2011/07/26 18:23:04
nit: extra \n
| |
OLD | NEW |