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

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

Issue 225283008: base: Add ScopedJavaLocalFrame class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Set kDefaultLocalFrameCapacity to 16. 512 is much higher than necessary and might fail. Created 6 years, 8 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
« no previous file with comments | « base/android/scoped_java_ref.h ('k') | content/app/android/child_process_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/android/scoped_java_ref.h" 5 #include "base/android/scoped_java_ref.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 9
10 namespace base { 10 namespace base {
11 namespace android { 11 namespace android {
12 namespace {
13
14 const int kDefaultLocalFrameCapacity = 16;
15
16 } // namespace
17
18 ScopedJavaLocalFrame::ScopedJavaLocalFrame(JNIEnv* env) : env_(env) {
19 int failed = env_->PushLocalFrame(kDefaultLocalFrameCapacity);
20 DCHECK(!failed);
21 }
22
23 ScopedJavaLocalFrame::ScopedJavaLocalFrame(JNIEnv* env, int capacity)
24 : env_(env) {
25 int failed = env_->PushLocalFrame(capacity);
26 DCHECK(!failed);
27 }
28
29 ScopedJavaLocalFrame::~ScopedJavaLocalFrame() { env_->PopLocalFrame(NULL); }
12 30
13 JavaRef<jobject>::JavaRef() : obj_(NULL) {} 31 JavaRef<jobject>::JavaRef() : obj_(NULL) {}
14 32
15 JavaRef<jobject>::JavaRef(JNIEnv* env, jobject obj) : obj_(obj) { 33 JavaRef<jobject>::JavaRef(JNIEnv* env, jobject obj) : obj_(obj) {
16 if (obj) { 34 if (obj) {
17 DCHECK(env && env->GetObjectRefType(obj) == JNILocalRefType); 35 DCHECK(env && env->GetObjectRefType(obj) == JNILocalRefType);
18 } 36 }
19 } 37 }
20 38
21 JavaRef<jobject>::~JavaRef() { 39 JavaRef<jobject>::~JavaRef() {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 } 82 }
65 83
66 jobject JavaRef<jobject>::ReleaseInternal() { 84 jobject JavaRef<jobject>::ReleaseInternal() {
67 jobject obj = obj_; 85 jobject obj = obj_;
68 obj_ = NULL; 86 obj_ = NULL;
69 return obj; 87 return obj;
70 } 88 }
71 89
72 } // namespace android 90 } // namespace android
73 } // namespace base 91 } // namespace base
OLDNEW
« no previous file with comments | « base/android/scoped_java_ref.h ('k') | content/app/android/child_process_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698