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

Side by Side Diff: content/app/android/child_process_service_impl.cc

Issue 2178973004: DialogSurfaceManager implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed IDialogSurfaceActivityMapper from common.aidl Created 4 years 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
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_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/android/unguessable_token_android.h" 13 #include "base/android/unguessable_token_android.h"
14 #include "base/lazy_instance.h" 14 #include "base/lazy_instance.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/posix/global_descriptors.h" 17 #include "base/posix/global_descriptors.h"
18 #include "base/unguessable_token.h" 18 #include "base/unguessable_token.h"
19 #include "content/child/child_thread_impl.h" 19 #include "content/child/child_thread_impl.h"
20 #include "content/public/common/content_descriptors.h" 20 #include "content/public/common/content_descriptors.h"
21 #include "gpu/ipc/common/android/dialog_surface_lookup.h"
21 #include "gpu/ipc/common/android/scoped_surface_request_conduit.h" 22 #include "gpu/ipc/common/android/scoped_surface_request_conduit.h"
22 #include "gpu/ipc/common/android/surface_texture_peer.h" 23 #include "gpu/ipc/common/android/surface_texture_peer.h"
23 #include "gpu/ipc/common/gpu_surface_lookup.h" 24 #include "gpu/ipc/common/gpu_surface_lookup.h"
24 #include "ipc/ipc_descriptors.h" 25 #include "ipc/ipc_descriptors.h"
25 #include "jni/ChildProcessServiceImpl_jni.h" 26 #include "jni/ChildProcessServiceImpl_jni.h"
26 #include "ui/gl/android/scoped_java_surface.h" 27 #include "ui/gl/android/scoped_java_surface.h"
27 28
28 using base::android::AttachCurrentThread; 29 using base::android::AttachCurrentThread;
29 using base::android::CheckException; 30 using base::android::CheckException;
30 using base::android::JavaIntArrayToIntVector; 31 using base::android::JavaIntArrayToIntVector;
31 using base::android::JavaParamRef; 32 using base::android::JavaParamRef;
32 33
33 namespace content { 34 namespace content {
34 35
35 namespace { 36 namespace {
36 37
37 // TODO(sievers): Use two different implementations of this depending on if 38 // TODO(sievers): Use two different implementations of this depending on if
38 // we're in a renderer or gpu process. 39 // we're in a renderer or gpu process.
39 class ChildProcessSurfaceManager : public gpu::SurfaceTexturePeer, 40 class ChildProcessSurfaceManager : 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 ChildProcessSurfaceManager() {} 45 ChildProcessSurfaceManager() {}
44 ~ChildProcessSurfaceManager() override {} 46 ~ChildProcessSurfaceManager() override {}
45 47
46 // |service impl| is the instance of 48 // |service impl| is the instance of
47 // org.chromium.content.app.ChildProcessServiceImpl. 49 // org.chromium.content.app.ChildProcessServiceImpl.
48 void SetServiceImpl(const base::android::JavaRef<jobject>& service_impl) { 50 void SetServiceImpl(const base::android::JavaRef<jobject>& service_impl) {
49 service_impl_.Reset(service_impl); 51 service_impl_.Reset(service_impl);
50 } 52 }
51 53
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 } 97 }
96 98
97 // Overridden from GpuSurfaceLookup: 99 // Overridden from GpuSurfaceLookup:
98 gl::ScopedJavaSurface AcquireJavaSurface(int surface_id) override { 100 gl::ScopedJavaSurface AcquireJavaSurface(int surface_id) override {
99 JNIEnv* env = base::android::AttachCurrentThread(); 101 JNIEnv* env = base::android::AttachCurrentThread();
100 return gl::ScopedJavaSurface( 102 return gl::ScopedJavaSurface(
101 content::Java_ChildProcessServiceImpl_getViewSurface(env, service_impl_, 103 content::Java_ChildProcessServiceImpl_getViewSurface(env, service_impl_,
102 surface_id)); 104 surface_id));
103 } 105 }
104 106
107 // Overridden from DialogSurfaceLookup:
108 base::android::ScopedJavaLocalRef<jobject> GetDialogSurfaceManager()
109 override {
110 JNIEnv* env = base::android::AttachCurrentThread();
111 return // base::android::ScopedJavaLocalRef<jobject>(
boliu 2017/01/04 23:14:39 commented out code
liberato (no reviews please) 2017/01/11 22:17:55 Done.
112 Java_ChildProcessServiceImpl_getDialogSurfaceManager(
113 env, service_impl_.obj());
114 }
115
105 private: 116 private:
106 friend struct base::DefaultLazyInstanceTraits<ChildProcessSurfaceManager>; 117 friend struct base::DefaultLazyInstanceTraits<ChildProcessSurfaceManager>;
107 // The instance of org.chromium.content.app.ChildProcessServiceImpl. 118 // The instance of org.chromium.content.app.ChildProcessServiceImpl.
108 base::android::ScopedJavaGlobalRef<jobject> service_impl_; 119 base::android::ScopedJavaGlobalRef<jobject> service_impl_;
109 120
110 DISALLOW_COPY_AND_ASSIGN(ChildProcessSurfaceManager); 121 DISALLOW_COPY_AND_ASSIGN(ChildProcessSurfaceManager);
111 }; 122 };
112 123
113 static base::LazyInstance<ChildProcessSurfaceManager>::Leaky 124 static base::LazyInstance<ChildProcessSurfaceManager>::Leaky
114 g_child_process_surface_manager = LAZY_INSTANCE_INITIALIZER; 125 g_child_process_surface_manager = LAZY_INSTANCE_INITIALIZER;
115 126
116 // Chrome actually uses the renderer code path for all of its child 127 // Chrome actually uses the renderer code path for all of its child
117 // processes such as renderers, plugins, etc. 128 // processes such as renderers, plugins, etc.
118 void InternalInitChildProcessImpl(JNIEnv* env, 129 void InternalInitChildProcessImpl(JNIEnv* env,
119 const JavaParamRef<jobject>& service_impl, 130 const JavaParamRef<jobject>& service_impl,
120 jint cpu_count, 131 jint cpu_count,
121 jlong cpu_features) { 132 jlong cpu_features) {
122 // Set the CPU properties. 133 // Set the CPU properties.
123 android_setCpu(cpu_count, cpu_features); 134 android_setCpu(cpu_count, cpu_features);
124 135
125 g_child_process_surface_manager.Get().SetServiceImpl(service_impl); 136 g_child_process_surface_manager.Get().SetServiceImpl(service_impl);
126 137
127 gpu::SurfaceTexturePeer::InitInstance( 138 gpu::SurfaceTexturePeer::InitInstance(
128 g_child_process_surface_manager.Pointer()); 139 g_child_process_surface_manager.Pointer());
129 gpu::GpuSurfaceLookup::InitInstance( 140 gpu::GpuSurfaceLookup::InitInstance(
130 g_child_process_surface_manager.Pointer()); 141 g_child_process_surface_manager.Pointer());
131 gpu::ScopedSurfaceRequestConduit::SetInstance( 142 gpu::ScopedSurfaceRequestConduit::SetInstance(
132 g_child_process_surface_manager.Pointer()); 143 g_child_process_surface_manager.Pointer());
144 gpu::DialogSurfaceLookup::InitInstance(
145 g_child_process_surface_manager.Pointer());
133 146
134 base::android::MemoryPressureListenerAndroid::RegisterSystemCallback(env); 147 base::android::MemoryPressureListenerAndroid::RegisterSystemCallback(env);
135 } 148 }
136 149
137 } // namespace <anonymous> 150 } // namespace <anonymous>
138 151
139 void RegisterGlobalFileDescriptor(JNIEnv* env, 152 void RegisterGlobalFileDescriptor(JNIEnv* env,
140 const JavaParamRef<jclass>& clazz, 153 const JavaParamRef<jclass>& clazz,
141 jint id, 154 jint id,
142 jint fd, 155 jint fd,
(...skipping 19 matching lines...) Expand all
162 175
163 bool RegisterChildProcessServiceImpl(JNIEnv* env) { 176 bool RegisterChildProcessServiceImpl(JNIEnv* env) {
164 return RegisterNativesImpl(env); 177 return RegisterNativesImpl(env);
165 } 178 }
166 179
167 void ShutdownMainThread(JNIEnv* env, const JavaParamRef<jobject>& obj) { 180 void ShutdownMainThread(JNIEnv* env, const JavaParamRef<jobject>& obj) {
168 ChildThreadImpl::ShutdownThread(); 181 ChildThreadImpl::ShutdownThread();
169 } 182 }
170 183
171 } // namespace content 184 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698