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

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: Updated base.gypi to exclude android directory for any non-Android OS Created 9 years, 5 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::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
OLDNEW
« no previous file with comments | « base/android/auto_jobject.h ('k') | base/base.gypi » ('j') | base/base.gypi » ('J')

Powered by Google App Engine
This is Rietveld 408576698