| 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_impl.h" | 5 #include "content/app/android/child_process_service_impl.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 "base/unguessable_token.h" | 16 #include "base/unguessable_token.h" |
| 17 #include "content/child/child_thread_impl.h" | 17 #include "content/child/child_thread_impl.h" |
| 18 #include "content/public/common/content_descriptors.h" | 18 #include "content/public/common/content_descriptors.h" |
| 19 #include "gpu/ipc/common/android/dialog_surface_lookup.h" |
| 19 #include "gpu/ipc/common/android/scoped_surface_request_conduit.h" | 20 #include "gpu/ipc/common/android/scoped_surface_request_conduit.h" |
| 20 #include "gpu/ipc/common/android/surface_texture_manager.h" | 21 #include "gpu/ipc/common/android/surface_texture_manager.h" |
| 21 #include "gpu/ipc/common/android/surface_texture_peer.h" | 22 #include "gpu/ipc/common/android/surface_texture_peer.h" |
| 22 #include "gpu/ipc/common/gpu_surface_lookup.h" | 23 #include "gpu/ipc/common/gpu_surface_lookup.h" |
| 23 #include "ipc/ipc_descriptors.h" | 24 #include "ipc/ipc_descriptors.h" |
| 24 #include "jni/ChildProcessServiceImpl_jni.h" | 25 #include "jni/ChildProcessServiceImpl_jni.h" |
| 25 #include "ui/gl/android/scoped_java_surface.h" | 26 #include "ui/gl/android/scoped_java_surface.h" |
| 26 | 27 |
| 27 using base::android::AttachCurrentThread; | 28 using base::android::AttachCurrentThread; |
| 28 using base::android::CheckException; | 29 using base::android::CheckException; |
| 29 using base::android::JavaIntArrayToIntVector; | 30 using base::android::JavaIntArrayToIntVector; |
| 30 using base::android::JavaParamRef; | 31 using base::android::JavaParamRef; |
| 31 | 32 |
| 32 namespace content { | 33 namespace content { |
| 33 | 34 |
| 34 namespace { | 35 namespace { |
| 35 | 36 |
| 36 // TODO(sievers): Use two different implementations of this depending on if | 37 // TODO(sievers): Use two different implementations of this depending on if |
| 37 // we're in a renderer or gpu process. | 38 // we're in a renderer or gpu process. |
| 38 class SurfaceTextureManagerImpl : public gpu::SurfaceTextureManager, | 39 class SurfaceTextureManagerImpl : public gpu::SurfaceTextureManager, |
| 39 public gpu::SurfaceTexturePeer, | 40 public gpu::SurfaceTexturePeer, |
| 40 public gpu::ScopedSurfaceRequestConduit, | 41 public gpu::ScopedSurfaceRequestConduit, |
| 41 public gpu::GpuSurfaceLookup { | 42 public gpu::GpuSurfaceLookup, |
| 43 public gpu::DialogSurfaceLookup { |
| 42 public: | 44 public: |
| 43 // |service impl| is the instance of | 45 // |service impl| is the instance of |
| 44 // org.chromium.content.app.ChildProcessServiceImpl. | 46 // org.chromium.content.app.ChildProcessServiceImpl. |
| 45 explicit SurfaceTextureManagerImpl( | 47 explicit SurfaceTextureManagerImpl( |
| 46 const base::android::JavaRef<jobject>& service_impl) | 48 const base::android::JavaRef<jobject>& service_impl) |
| 47 : service_impl_(service_impl) { | 49 : service_impl_(service_impl) { |
| 48 SurfaceTexturePeer::InitInstance(this); | 50 SurfaceTexturePeer::InitInstance(this); |
| 49 gpu::GpuSurfaceLookup::InitInstance(this); | 51 gpu::GpuSurfaceLookup::InitInstance(this); |
| 50 gpu::ScopedSurfaceRequestConduit::SetInstance(this); | 52 gpu::ScopedSurfaceRequestConduit::SetInstance(this); |
| 53 gpu::DialogSurfaceLookup::InitInstance(this); |
| 51 } | 54 } |
| 52 ~SurfaceTextureManagerImpl() override { | 55 ~SurfaceTextureManagerImpl() override { |
| 53 SurfaceTexturePeer::InitInstance(NULL); | 56 SurfaceTexturePeer::InitInstance(NULL); |
| 54 gpu::GpuSurfaceLookup::InitInstance(NULL); | 57 gpu::GpuSurfaceLookup::InitInstance(NULL); |
| 55 gpu::ScopedSurfaceRequestConduit::SetInstance(nullptr); | 58 gpu::ScopedSurfaceRequestConduit::SetInstance(nullptr); |
| 59 gpu::DialogSurfaceLookup::InitInstance(NULL); |
| 56 } | 60 } |
| 57 | 61 |
| 58 // Overridden from SurfaceTextureManager: | 62 // Overridden from SurfaceTextureManager: |
| 59 void RegisterSurfaceTexture(int surface_texture_id, | 63 void RegisterSurfaceTexture(int surface_texture_id, |
| 60 int client_id, | 64 int client_id, |
| 61 gl::SurfaceTexture* surface_texture) override { | 65 gl::SurfaceTexture* surface_texture) override { |
| 62 JNIEnv* env = base::android::AttachCurrentThread(); | 66 JNIEnv* env = base::android::AttachCurrentThread(); |
| 63 Java_ChildProcessServiceImpl_createSurfaceTextureSurface( | 67 Java_ChildProcessServiceImpl_createSurfaceTextureSurface( |
| 64 env, service_impl_, surface_texture_id, client_id, | 68 env, service_impl_, surface_texture_id, client_id, |
| 65 surface_texture->j_surface_texture()); | 69 surface_texture->j_surface_texture()); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 } | 140 } |
| 137 | 141 |
| 138 // Overridden from GpuSurfaceLookup: | 142 // Overridden from GpuSurfaceLookup: |
| 139 gl::ScopedJavaSurface AcquireJavaSurface(int surface_id) override { | 143 gl::ScopedJavaSurface AcquireJavaSurface(int surface_id) override { |
| 140 JNIEnv* env = base::android::AttachCurrentThread(); | 144 JNIEnv* env = base::android::AttachCurrentThread(); |
| 141 return gl::ScopedJavaSurface( | 145 return gl::ScopedJavaSurface( |
| 142 content::Java_ChildProcessServiceImpl_getViewSurface(env, service_impl_, | 146 content::Java_ChildProcessServiceImpl_getViewSurface(env, service_impl_, |
| 143 surface_id)); | 147 surface_id)); |
| 144 } | 148 } |
| 145 | 149 |
| 150 // Overridden from DialogSurfaceLookup: |
| 151 base::android::ScopedJavaLocalRef<jobject> GetDialogSurfaceManager() |
| 152 override { |
| 153 JNIEnv* env = base::android::AttachCurrentThread(); |
| 154 return base::android::ScopedJavaLocalRef<jobject>( |
| 155 content::Java_ChildProcessServiceImpl_getDialogSurfaceManager( |
| 156 env, service_impl_.obj())); |
| 157 } |
| 158 |
| 146 private: | 159 private: |
| 147 // The instance of org.chromium.content.app.ChildProcessServiceImpl. | 160 // The instance of org.chromium.content.app.ChildProcessServiceImpl. |
| 148 base::android::ScopedJavaGlobalRef<jobject> service_impl_; | 161 base::android::ScopedJavaGlobalRef<jobject> service_impl_; |
| 149 | 162 |
| 150 DISALLOW_COPY_AND_ASSIGN(SurfaceTextureManagerImpl); | 163 DISALLOW_COPY_AND_ASSIGN(SurfaceTextureManagerImpl); |
| 151 }; | 164 }; |
| 152 | 165 |
| 153 // Chrome actually uses the renderer code path for all of its child | 166 // Chrome actually uses the renderer code path for all of its child |
| 154 // processes such as renderers, plugins, etc. | 167 // processes such as renderers, plugins, etc. |
| 155 void InternalInitChildProcessImpl(JNIEnv* env, | 168 void InternalInitChildProcessImpl(JNIEnv* env, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 | 205 |
| 193 bool RegisterChildProcessServiceImpl(JNIEnv* env) { | 206 bool RegisterChildProcessServiceImpl(JNIEnv* env) { |
| 194 return RegisterNativesImpl(env); | 207 return RegisterNativesImpl(env); |
| 195 } | 208 } |
| 196 | 209 |
| 197 void ShutdownMainThread(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 210 void ShutdownMainThread(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 198 ChildThreadImpl::ShutdownThread(); | 211 ChildThreadImpl::ShutdownThread(); |
| 199 } | 212 } |
| 200 | 213 |
| 201 } // namespace content | 214 } // namespace content |
| OLD | NEW |