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(JNIEnv* env, jobject obj) |
| 13 : env_(env), |
| 14 obj_(obj) { |
| 15 } |
| 16 |
| 17 AutoJObject::AutoJObject(const AutoJObject& other) |
| 18 : env_(other.env_), |
| 19 obj_(other.obj_ ? other.env_->NewLocalRef(other.obj_) : NULL) { |
| 20 } |
| 21 |
| 22 AutoJObject::~AutoJObject() { |
| 23 if (obj_) |
| 24 env_->DeleteLocalRef(obj_); |
| 25 } |
| 26 |
| 27 jobject AutoJObject::Release() { |
| 28 jobject obj = obj_; |
| 29 obj_ = NULL; |
| 30 return obj; |
| 31 } |
| 32 |
| 33 } // namespace android |
| 34 } // namespace base |
OLD | NEW |