| Index: base/android/auto_jobject.cc
|
| diff --git a/base/android/auto_jobject.cc b/base/android/auto_jobject.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..0d9f124826fa3ef8afa9b3ea1fc552ebd3248a7f
|
| --- /dev/null
|
| +++ b/base/android/auto_jobject.cc
|
| @@ -0,0 +1,46 @@
|
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "base/android/auto_jobject.h"
|
| +
|
| +#include <stddef.h>
|
| +
|
| +namespace base {
|
| +namespace android {
|
| +
|
| +AutoJObject AutoJObject::FromLocalRef(JNIEnv* env, jobject obj) {
|
| + return AutoJObject(env, obj);
|
| +}
|
| +
|
| +AutoJObject::AutoJObject(const AutoJObject& other)
|
| + : env_(other.env_),
|
| + obj_(other.obj_ ? other.env_->NewLocalRef(other.obj_) : NULL) {
|
| +}
|
| +
|
| +AutoJObject::AutoJObject(JNIEnv* env, jobject obj)
|
| + : env_(env),
|
| + obj_(obj) {
|
| +}
|
| +
|
| +AutoJObject::~AutoJObject() {
|
| + if (obj_)
|
| + env_->DeleteLocalRef(obj_);
|
| +}
|
| +
|
| +JNIEnv* AutoJObject::env() const {
|
| + return env_;
|
| +}
|
| +
|
| +jobject AutoJObject::obj() const {
|
| + return obj_;
|
| +}
|
| +
|
| +jobject AutoJObject::Release() {
|
| + jobject obj = obj_;
|
| + obj_ = NULL;
|
| + return obj;
|
| +}
|
| +
|
| +} // namespace android
|
| +} // namespace base
|
|
|