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

Side by Side Diff: content/app/android/child_process_service.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
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 "content/app/android/child_process_service.h" 5 #include "content/app/android/child_process_service.h"
6 6
7 #include <android/native_window_jni.h> 7 #include <android/native_window_jni.h>
8 #include <cpu-features.h> 8 #include <cpu-features.h>
9 9
10 #include "base/android/jni_array.h" 10 #include "base/android/jni_array.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 // Overridden from GpuSurfaceLookup: 65 // Overridden from GpuSurfaceLookup:
66 virtual gfx::AcceleratedWidget AcquireNativeWidget(int surface_id) OVERRIDE { 66 virtual gfx::AcceleratedWidget AcquireNativeWidget(int surface_id) OVERRIDE {
67 JNIEnv* env = base::android::AttachCurrentThread(); 67 JNIEnv* env = base::android::AttachCurrentThread();
68 gfx::ScopedJavaSurface surface( 68 gfx::ScopedJavaSurface surface(
69 content::Java_ChildProcessService_getViewSurface( 69 content::Java_ChildProcessService_getViewSurface(
70 env, service_.obj(), surface_id)); 70 env, service_.obj(), surface_id));
71 71
72 if (surface.j_surface().is_null()) 72 if (surface.j_surface().is_null())
73 return NULL; 73 return NULL;
74 74
75 ANativeWindow* native_window = ANativeWindow_fromSurface( 75 // Note: This ensures that any local references used by
76 env, surface.j_surface().obj()); 76 // ANativeWindow_fromSurface are released immediately. This is needed as a
77 // workaround for https://code.google.com/p/android/issues/detail?id=68174
78 base::android::ScopedJavaLocalFrame scoped_local_reference_frame(env);
79 ANativeWindow* native_window =
80 ANativeWindow_fromSurface(env, surface.j_surface().obj());
77 81
78 return native_window; 82 return native_window;
79 } 83 }
80 84
81 // Overridden from SurfaceTextureLookup: 85 // Overridden from SurfaceTextureLookup:
82 virtual gfx::AcceleratedWidget AcquireNativeWidget(int primary_id, 86 virtual gfx::AcceleratedWidget AcquireNativeWidget(int primary_id,
83 int secondary_id) 87 int secondary_id)
84 OVERRIDE { 88 OVERRIDE {
85 JNIEnv* env = base::android::AttachCurrentThread(); 89 JNIEnv* env = base::android::AttachCurrentThread();
86 gfx::ScopedJavaSurface surface( 90 gfx::ScopedJavaSurface surface(
87 content::Java_ChildProcessService_getSurfaceTextureSurface( 91 content::Java_ChildProcessService_getSurfaceTextureSurface(
88 env, service_.obj(), primary_id, secondary_id)); 92 env, service_.obj(), primary_id, secondary_id));
89 93
90 if (surface.j_surface().is_null()) 94 if (surface.j_surface().is_null())
91 return NULL; 95 return NULL;
92 96
97 // Note: This ensures that any local references used by
98 // ANativeWindow_fromSurface are released immediately. This is needed as a
99 // workaround for https://code.google.com/p/android/issues/detail?id=68174
100 base::android::ScopedJavaLocalFrame scoped_local_reference_frame(env);
93 ANativeWindow* native_window = 101 ANativeWindow* native_window =
94 ANativeWindow_fromSurface(env, surface.j_surface().obj()); 102 ANativeWindow_fromSurface(env, surface.j_surface().obj());
95 103
96 return native_window; 104 return native_window;
97 } 105 }
98 106
99 private: 107 private:
100 // The instance of org.chromium.content.app.ChildProcessService. 108 // The instance of org.chromium.content.app.ChildProcessService.
101 base::android::ScopedJavaGlobalRef<jobject> service_; 109 base::android::ScopedJavaGlobalRef<jobject> service_;
102 110
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 169
162 bool RegisterChildProcessService(JNIEnv* env) { 170 bool RegisterChildProcessService(JNIEnv* env) {
163 return RegisterNativesImpl(env); 171 return RegisterNativesImpl(env);
164 } 172 }
165 173
166 void ShutdownMainThread(JNIEnv* env, jobject obj) { 174 void ShutdownMainThread(JNIEnv* env, jobject obj) {
167 ChildThread::ShutdownThread(); 175 ChildThread::ShutdownThread();
168 } 176 }
169 177
170 } // namespace content 178 } // namespace content
OLDNEW
« no previous file with comments | « base/android/scoped_java_ref.cc ('k') | content/browser/renderer_host/compositor_impl_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698