| OLD | NEW |
| 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" |
| 11 #include "base/android/library_loader/library_loader_hooks.h" | 11 #include "base/android/library_loader/library_loader_hooks.h" |
| 12 #include "base/android/memory_pressure_listener_android.h" | 12 #include "base/android/memory_pressure_listener_android.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/posix/global_descriptors.h" | 15 #include "base/posix/global_descriptors.h" |
| 16 #include "content/child/child_thread_impl.h" | 16 #include "content/child/child_thread_impl.h" |
| 17 #include "content/common/android/surface_texture_manager.h" | |
| 18 #include "content/common/android/surface_texture_peer.h" | |
| 19 #include "content/common/gpu/gpu_surface_lookup.h" | 17 #include "content/common/gpu/gpu_surface_lookup.h" |
| 20 #include "content/public/common/content_descriptors.h" | 18 #include "content/public/common/content_descriptors.h" |
| 19 #include "gpu/ipc/common/android/surface_texture_manager.h" |
| 20 #include "gpu/ipc/common/android/surface_texture_peer.h" |
| 21 #include "ipc/ipc_descriptors.h" | 21 #include "ipc/ipc_descriptors.h" |
| 22 #include "jni/ChildProcessService_jni.h" | 22 #include "jni/ChildProcessService_jni.h" |
| 23 #include "ui/gl/android/scoped_java_surface.h" | 23 #include "ui/gl/android/scoped_java_surface.h" |
| 24 | 24 |
| 25 using base::android::AttachCurrentThread; | 25 using base::android::AttachCurrentThread; |
| 26 using base::android::CheckException; | 26 using base::android::CheckException; |
| 27 using base::android::JavaIntArrayToIntVector; | 27 using base::android::JavaIntArrayToIntVector; |
| 28 | 28 |
| 29 namespace content { | 29 namespace content { |
| 30 | 30 |
| 31 namespace { | 31 namespace { |
| 32 | 32 |
| 33 // TODO(sievers): Use two different implementations of this depending on if | 33 // TODO(sievers): Use two different implementations of this depending on if |
| 34 // we're in a renderer or gpu process. | 34 // we're in a renderer or gpu process. |
| 35 class SurfaceTextureManagerImpl : public SurfaceTextureManager, | 35 class SurfaceTextureManagerImpl : public gpu::SurfaceTextureManager, |
| 36 public SurfaceTexturePeer, | 36 public gpu::SurfaceTexturePeer, |
| 37 public GpuSurfaceLookup { | 37 public GpuSurfaceLookup { |
| 38 public: | 38 public: |
| 39 // |service| is the instance of | 39 // |service| is the instance of |
| 40 // org.chromium.content.app.ChildProcessService. | 40 // org.chromium.content.app.ChildProcessService. |
| 41 explicit SurfaceTextureManagerImpl( | 41 explicit SurfaceTextureManagerImpl( |
| 42 const base::android::JavaRef<jobject>& service) | 42 const base::android::JavaRef<jobject>& service) |
| 43 : service_(service) { | 43 : service_(service) { |
| 44 SurfaceTexturePeer::InitInstance(this); | 44 SurfaceTexturePeer::InitInstance(this); |
| 45 GpuSurfaceLookup::InitInstance(this); | 45 GpuSurfaceLookup::InitInstance(this); |
| 46 } | 46 } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 }; | 139 }; |
| 140 | 140 |
| 141 // Chrome actually uses the renderer code path for all of its child | 141 // Chrome actually uses the renderer code path for all of its child |
| 142 // processes such as renderers, plugins, etc. | 142 // processes such as renderers, plugins, etc. |
| 143 void InternalInitChildProcess(JNIEnv* env, | 143 void InternalInitChildProcess(JNIEnv* env, |
| 144 const JavaParamRef<jobject>& service, | 144 const JavaParamRef<jobject>& service, |
| 145 jint cpu_count, | 145 jint cpu_count, |
| 146 jlong cpu_features) { | 146 jlong cpu_features) { |
| 147 // Set the CPU properties. | 147 // Set the CPU properties. |
| 148 android_setCpu(cpu_count, cpu_features); | 148 android_setCpu(cpu_count, cpu_features); |
| 149 SurfaceTextureManager::SetInstance(new SurfaceTextureManagerImpl(service)); | 149 gpu::SurfaceTextureManager::SetInstance( |
| 150 new SurfaceTextureManagerImpl(service)); |
| 150 | 151 |
| 151 base::android::MemoryPressureListenerAndroid::RegisterSystemCallback(env); | 152 base::android::MemoryPressureListenerAndroid::RegisterSystemCallback(env); |
| 152 } | 153 } |
| 153 | 154 |
| 154 } // namespace <anonymous> | 155 } // namespace <anonymous> |
| 155 | 156 |
| 156 void RegisterGlobalFileDescriptor(JNIEnv* env, | 157 void RegisterGlobalFileDescriptor(JNIEnv* env, |
| 157 const JavaParamRef<jclass>& clazz, | 158 const JavaParamRef<jclass>& clazz, |
| 158 jint id, | 159 jint id, |
| 159 jint fd, | 160 jint fd, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 179 | 180 |
| 180 bool RegisterChildProcessService(JNIEnv* env) { | 181 bool RegisterChildProcessService(JNIEnv* env) { |
| 181 return RegisterNativesImpl(env); | 182 return RegisterNativesImpl(env); |
| 182 } | 183 } |
| 183 | 184 |
| 184 void ShutdownMainThread(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 185 void ShutdownMainThread(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 185 ChildThreadImpl::ShutdownThread(); | 186 ChildThreadImpl::ShutdownThread(); |
| 186 } | 187 } |
| 187 | 188 |
| 188 } // namespace content | 189 } // namespace content |
| OLD | NEW |