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..0a92fc8f070108728f3d8248ae478b155d81ab3a |
--- /dev/null |
+++ b/base/android/auto_jobject.cc |
@@ -0,0 +1,34 @@ |
+// 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(JNIEnv* env, jobject obj) |
+ : env_(env), |
+ obj_(obj) { |
+} |
+ |
+AutoJObject::AutoJObject(const AutoJObject& other) |
+ : env_(other.env_), |
+ obj_(other.obj_ ? other.env_->NewLocalRef(other.obj_) : NULL) { |
+} |
+ |
+AutoJObject::~AutoJObject() { |
+ if (obj_) |
+ env_->DeleteLocalRef(obj_); |
+} |
+ |
+jobject AutoJObject::Release() { |
+ jobject obj = obj_; |
+ obj_ = NULL; |
+ return obj; |
+} |
+ |
+} // namespace android |
+} // namespace base |