OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 package org.chromium.content.browser; | 5 package org.chromium.content.browser; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.graphics.SurfaceTexture; | 8 import android.graphics.SurfaceTexture; |
9 import android.os.RemoteException; | 9 import android.os.RemoteException; |
10 import android.util.Log; | 10 import android.util.Log; |
11 import android.util.Pair; | 11 import android.util.Pair; |
12 import android.view.Surface; | 12 import android.view.Surface; |
13 | 13 |
14 import com.google.common.annotations.VisibleForTesting; | 14 import com.google.common.annotations.VisibleForTesting; |
15 | 15 |
16 import org.chromium.base.BaseSwitches; | |
16 import org.chromium.base.CalledByNative; | 17 import org.chromium.base.CalledByNative; |
18 import org.chromium.base.CommandLine; | |
17 import org.chromium.base.JNINamespace; | 19 import org.chromium.base.JNINamespace; |
18 import org.chromium.base.ThreadUtils; | 20 import org.chromium.base.ThreadUtils; |
19 import org.chromium.base.TraceEvent; | 21 import org.chromium.base.TraceEvent; |
20 import org.chromium.base.library_loader.Linker; | 22 import org.chromium.base.library_loader.Linker; |
21 import org.chromium.content.app.ChildProcessService; | 23 import org.chromium.content.app.ChildProcessService; |
22 import org.chromium.content.app.ChromiumLinkerParams; | 24 import org.chromium.content.app.ChromiumLinkerParams; |
23 import org.chromium.content.app.PrivilegedProcessService; | 25 import org.chromium.content.app.PrivilegedProcessService; |
24 import org.chromium.content.app.SandboxedProcessService; | 26 import org.chromium.content.app.SandboxedProcessService; |
25 import org.chromium.content.common.IChildProcessCallback; | 27 import org.chromium.content.common.IChildProcessCallback; |
26 import org.chromium.content.common.SurfaceWrapper; | 28 import org.chromium.content.common.SurfaceWrapper; |
27 | 29 |
28 import java.util.ArrayList; | 30 import java.util.ArrayList; |
31 import java.util.Arrays; | |
29 import java.util.Map; | 32 import java.util.Map; |
30 import java.util.concurrent.ConcurrentHashMap; | 33 import java.util.concurrent.ConcurrentHashMap; |
31 | 34 |
32 /** | 35 /** |
33 * This class provides the method to start/stop ChildProcess called by native. | 36 * This class provides the method to start/stop ChildProcess called by native. |
34 */ | 37 */ |
35 @JNINamespace("content") | 38 @JNINamespace("content") |
36 public class ChildProcessLauncher { | 39 public class ChildProcessLauncher { |
37 private static final String TAG = "ChildProcessLauncher"; | 40 private static final String TAG = "ChildProcessLauncher"; |
38 | 41 |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
351 FileDescriptorInfo[] filesToBeMapped = new FileDescriptorInfo[fileFds.le ngth]; | 354 FileDescriptorInfo[] filesToBeMapped = new FileDescriptorInfo[fileFds.le ngth]; |
352 for (int i = 0; i < fileFds.length; i++) { | 355 for (int i = 0; i < fileFds.length; i++) { |
353 filesToBeMapped[i] = | 356 filesToBeMapped[i] = |
354 new FileDescriptorInfo(fileIds[i], fileFds[i], fileAutoClose [i]); | 357 new FileDescriptorInfo(fileIds[i], fileFds[i], fileAutoClose [i]); |
355 } | 358 } |
356 assert clientContext != 0; | 359 assert clientContext != 0; |
357 | 360 |
358 int callbackType = CALLBACK_FOR_UNKNOWN_PROCESS; | 361 int callbackType = CALLBACK_FOR_UNKNOWN_PROCESS; |
359 boolean inSandbox = true; | 362 boolean inSandbox = true; |
360 String processType = getSwitchValue(commandLine, SWITCH_PROCESS_TYPE); | 363 String processType = getSwitchValue(commandLine, SWITCH_PROCESS_TYPE); |
364 ArrayList<String> cmdList = commandLine == null ? new ArrayList<String>( ) : | |
365 new ArrayList<String>(Arrays.asList(commandLine)); | |
Feng Qian
2014/08/27 17:45:29
We should put render command line options in one p
Jaekyun Seok (inactive)
2014/08/28 00:09:49
Done.
| |
361 if (SWITCH_RENDERER_PROCESS.equals(processType)) { | 366 if (SWITCH_RENDERER_PROCESS.equals(processType)) { |
367 if (CommandLine.getInstance().hasSwitch( | |
368 BaseSwitches.WAIT_RENDERER_FOR_JAVA_DEBUGGER)) { | |
369 cmdList.add("--" + BaseSwitches.WAIT_FOR_JAVA_DEBUGGER); | |
370 } | |
362 callbackType = CALLBACK_FOR_RENDERER_PROCESS; | 371 callbackType = CALLBACK_FOR_RENDERER_PROCESS; |
363 } else if (SWITCH_GPU_PROCESS.equals(processType)) { | 372 } else if (SWITCH_GPU_PROCESS.equals(processType)) { |
364 callbackType = CALLBACK_FOR_GPU_PROCESS; | 373 callbackType = CALLBACK_FOR_GPU_PROCESS; |
365 } else if (SWITCH_PPAPI_BROKER_PROCESS.equals(processType)) { | 374 } else if (SWITCH_PPAPI_BROKER_PROCESS.equals(processType)) { |
366 inSandbox = false; | 375 inSandbox = false; |
367 } | 376 } |
377 String[] updatedCommandLine = cmdList.toArray(new String[0]); | |
368 | 378 |
369 ChildProcessConnection allocatedConnection = null; | 379 ChildProcessConnection allocatedConnection = null; |
370 synchronized (ChildProcessLauncher.class) { | 380 synchronized (ChildProcessLauncher.class) { |
371 if (inSandbox) { | 381 if (inSandbox) { |
372 allocatedConnection = sSpareSandboxedConnection; | 382 allocatedConnection = sSpareSandboxedConnection; |
373 sSpareSandboxedConnection = null; | 383 sSpareSandboxedConnection = null; |
374 } | 384 } |
375 } | 385 } |
376 if (allocatedConnection == null) { | 386 if (allocatedConnection == null) { |
377 allocatedConnection = allocateBoundConnection(context, commandLine, inSandbox); | 387 allocatedConnection = allocateBoundConnection(context, updatedComman dLine, inSandbox); |
378 if (allocatedConnection == null) { | 388 if (allocatedConnection == null) { |
379 // Notify the native code so it can free the heap allocated call back. | 389 // Notify the native code so it can free the heap allocated call back. |
380 nativeOnChildProcessStarted(clientContext, 0); | 390 nativeOnChildProcessStarted(clientContext, 0); |
381 Log.e(TAG, "Allocation of new service failed."); | 391 Log.e(TAG, "Allocation of new service failed."); |
382 TraceEvent.end(); | 392 TraceEvent.end(); |
383 return; | 393 return; |
384 } | 394 } |
385 } | 395 } |
386 | 396 |
387 Log.d(TAG, "Setting up connection to process: slot=" + | 397 Log.d(TAG, "Setting up connection to process: slot=" + |
388 allocatedConnection.getServiceNumber()); | 398 allocatedConnection.getServiceNumber()); |
389 triggerConnectionSetup(allocatedConnection, commandLine, childProcessId, filesToBeMapped, | 399 triggerConnectionSetup(allocatedConnection, updatedCommandLine, childPro cessId, |
390 callbackType, clientContext); | 400 filesToBeMapped, callbackType, clientContext); |
391 TraceEvent.end(); | 401 TraceEvent.end(); |
392 } | 402 } |
393 | 403 |
394 @VisibleForTesting | 404 @VisibleForTesting |
395 static void triggerConnectionSetup( | 405 static void triggerConnectionSetup( |
396 final ChildProcessConnection connection, | 406 final ChildProcessConnection connection, |
397 String[] commandLine, | 407 String[] commandLine, |
398 int childProcessId, | 408 int childProcessId, |
399 FileDescriptorInfo[] filesToBeMapped, | 409 FileDescriptorInfo[] filesToBeMapped, |
400 int callbackType, | 410 int callbackType, |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
551 } | 561 } |
552 | 562 |
553 return true; | 563 return true; |
554 } | 564 } |
555 | 565 |
556 private static native void nativeOnChildProcessStarted(long clientContext, i nt pid); | 566 private static native void nativeOnChildProcessStarted(long clientContext, i nt pid); |
557 private static native void nativeEstablishSurfacePeer( | 567 private static native void nativeEstablishSurfacePeer( |
558 int pid, Surface surface, int primaryID, int secondaryID); | 568 int pid, Surface surface, int primaryID, int secondaryID); |
559 private static native boolean nativeIsSingleProcess(); | 569 private static native boolean nativeIsSingleProcess(); |
560 } | 570 } |
OLD | NEW |