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

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

Issue 7480016: Add AutoJObject and AutoGlobalJObject (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Removed FromLocalRef() Created 9 years, 4 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 #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
OLDNEW
« base/android/auto_jobject.h ('K') | « base/android/auto_jobject.h ('k') | base/base.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698