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/browser/android/child_process_launcher_android.h" | 5 #include "content/browser/android/child_process_launcher_android.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 | 95 |
96 JNIEnv* env = AttachCurrentThread(); | 96 JNIEnv* env = AttachCurrentThread(); |
97 DCHECK(env); | 97 DCHECK(env); |
98 | 98 |
99 // Create the Command line String[] | 99 // Create the Command line String[] |
100 ScopedJavaLocalRef<jobjectArray> j_argv = | 100 ScopedJavaLocalRef<jobjectArray> j_argv = |
101 ToJavaArrayOfStrings(env, cmd_line->argv()); | 101 ToJavaArrayOfStrings(env, cmd_line->argv()); |
102 | 102 |
103 // TODO(qinmin): pass download parameters here. | 103 // TODO(qinmin): pass download parameters here. |
104 Java_ChildProcessLauncher_startDownloadProcessIfNecessary( | 104 Java_ChildProcessLauncher_startDownloadProcessIfNecessary( |
105 env, base::android::GetApplicationContext(), j_argv.obj()); | 105 env, base::android::GetApplicationContext(), j_argv); |
106 } | 106 } |
107 | 107 |
108 } // anonymous namespace | 108 } // anonymous namespace |
109 | 109 |
110 // Called from ChildProcessLauncher.java when the ChildProcess was | 110 // Called from ChildProcessLauncher.java when the ChildProcess was |
111 // started. | 111 // started. |
112 // |client_context| is the pointer to StartChildProcessCallback which was | 112 // |client_context| is the pointer to StartChildProcessCallback which was |
113 // passed in from StartChildProcess. | 113 // passed in from StartChildProcess. |
114 // |handle| is the processID of the child process as originated in Java, 0 if | 114 // |handle| is the processID of the child process as originated in Java, 0 if |
115 // the ChildProcess could not be created. | 115 // the ChildProcess could not be created. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 Java_ChildProcessLauncher_makeFdInfo(env, id, fd, auto_close, offset, | 187 Java_ChildProcessLauncher_makeFdInfo(env, id, fd, auto_close, offset, |
188 size); | 188 size); |
189 PCHECK(j_file_info.obj()); | 189 PCHECK(j_file_info.obj()); |
190 env->SetObjectArrayElement(j_file_infos.obj(), i, j_file_info.obj()); | 190 env->SetObjectArrayElement(j_file_infos.obj(), i, j_file_info.obj()); |
191 if (auto_close) { | 191 if (auto_close) { |
192 ignore_result(files_to_register->ReleaseFD(fd).release()); | 192 ignore_result(files_to_register->ReleaseFD(fd).release()); |
193 } | 193 } |
194 } | 194 } |
195 | 195 |
196 Java_ChildProcessLauncher_start( | 196 Java_ChildProcessLauncher_start( |
197 env, base::android::GetApplicationContext(), j_argv.obj(), | 197 env, base::android::GetApplicationContext(), j_argv, child_process_id, |
198 child_process_id, j_file_infos.obj(), | 198 j_file_infos, |
199 reinterpret_cast<intptr_t>(new StartChildProcessCallback(callback))); | 199 reinterpret_cast<intptr_t>(new StartChildProcessCallback(callback))); |
200 } | 200 } |
201 | 201 |
202 void StopChildProcess(base::ProcessHandle handle) { | 202 void StopChildProcess(base::ProcessHandle handle) { |
203 JNIEnv* env = AttachCurrentThread(); | 203 JNIEnv* env = AttachCurrentThread(); |
204 DCHECK(env); | 204 DCHECK(env); |
205 Java_ChildProcessLauncher_stop(env, static_cast<jint>(handle)); | 205 Java_ChildProcessLauncher_stop(env, static_cast<jint>(handle)); |
206 } | 206 } |
207 | 207 |
208 bool IsChildProcessOomProtected(base::ProcessHandle handle) { | 208 bool IsChildProcessOomProtected(base::ProcessHandle handle) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 return gl::ScopedJavaSurface::AcquireExternalSurface( | 254 return gl::ScopedJavaSurface::AcquireExternalSurface( |
255 Java_ChildProcessLauncher_getViewSurface(env, surface_id).obj()); | 255 Java_ChildProcessLauncher_getViewSurface(env, surface_id).obj()); |
256 } | 256 } |
257 | 257 |
258 void CreateSurfaceTextureSurface(int surface_texture_id, | 258 void CreateSurfaceTextureSurface(int surface_texture_id, |
259 int client_id, | 259 int client_id, |
260 gl::SurfaceTexture* surface_texture) { | 260 gl::SurfaceTexture* surface_texture) { |
261 JNIEnv* env = AttachCurrentThread(); | 261 JNIEnv* env = AttachCurrentThread(); |
262 DCHECK(env); | 262 DCHECK(env); |
263 Java_ChildProcessLauncher_createSurfaceTextureSurface( | 263 Java_ChildProcessLauncher_createSurfaceTextureSurface( |
264 env, | 264 env, surface_texture_id, client_id, surface_texture->j_surface_texture()); |
265 surface_texture_id, | |
266 client_id, | |
267 surface_texture->j_surface_texture().obj()); | |
268 } | 265 } |
269 | 266 |
270 void DestroySurfaceTextureSurface(int surface_texture_id, int client_id) { | 267 void DestroySurfaceTextureSurface(int surface_texture_id, int client_id) { |
271 JNIEnv* env = AttachCurrentThread(); | 268 JNIEnv* env = AttachCurrentThread(); |
272 DCHECK(env); | 269 DCHECK(env); |
273 Java_ChildProcessLauncher_destroySurfaceTextureSurface( | 270 Java_ChildProcessLauncher_destroySurfaceTextureSurface( |
274 env, surface_texture_id, client_id); | 271 env, surface_texture_id, client_id); |
275 } | 272 } |
276 | 273 |
277 gl::ScopedJavaSurface GetSurfaceTextureSurface(int surface_texture_id, | 274 gl::ScopedJavaSurface GetSurfaceTextureSurface(int surface_texture_id, |
278 int client_id) { | 275 int client_id) { |
279 JNIEnv* env = AttachCurrentThread(); | 276 JNIEnv* env = AttachCurrentThread(); |
280 DCHECK(env); | 277 DCHECK(env); |
281 return gl::ScopedJavaSurface::AcquireExternalSurface( | 278 return gl::ScopedJavaSurface::AcquireExternalSurface( |
282 Java_ChildProcessLauncher_getSurfaceTextureSurface( | 279 Java_ChildProcessLauncher_getSurfaceTextureSurface( |
283 env, surface_texture_id, client_id) | 280 env, surface_texture_id, client_id) |
284 .obj()); | 281 .obj()); |
285 } | 282 } |
286 | 283 |
287 jboolean IsSingleProcess(JNIEnv* env, const JavaParamRef<jclass>& clazz) { | 284 jboolean IsSingleProcess(JNIEnv* env, const JavaParamRef<jclass>& clazz) { |
288 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 285 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
289 switches::kSingleProcess); | 286 switches::kSingleProcess); |
290 } | 287 } |
291 | 288 |
292 bool RegisterChildProcessLauncher(JNIEnv* env) { | 289 bool RegisterChildProcessLauncher(JNIEnv* env) { |
293 return RegisterNativesImpl(env); | 290 return RegisterNativesImpl(env); |
294 } | 291 } |
295 | 292 |
296 } // namespace content | 293 } // namespace content |
OLD | NEW |