| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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.os.ParcelFileDescriptor; | 8 import android.os.ParcelFileDescriptor; |
| 9 | 9 |
| 10 import org.chromium.base.ContextUtils; | 10 import org.chromium.base.ContextUtils; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 } catch (IOException e) { | 46 } catch (IOException e) { |
| 47 Log.e(TAG, "Invalid FD provided for process connection, aborting
connection.", e); | 47 Log.e(TAG, "Invalid FD provided for process connection, aborting
connection.", e); |
| 48 return null; | 48 return null; |
| 49 } | 49 } |
| 50 } | 50 } |
| 51 return new FileDescriptorInfo(id, pFd, offset, size); | 51 return new FileDescriptorInfo(id, pFd, offset, size); |
| 52 } | 52 } |
| 53 | 53 |
| 54 @CalledByNative | 54 @CalledByNative |
| 55 private static ChildProcessLauncherHelper create(long nativePointer, int par
amId, | 55 private static ChildProcessLauncherHelper create(long nativePointer, int par
amId, |
| 56 final String[] commandLine, int childProcessId, FileDescriptorInfo[]
filesToBeMapped) { | 56 final String[] commandLine, FileDescriptorInfo[] filesToBeMapped) { |
| 57 assert LauncherThread.runningOnLauncherThread(); | 57 assert LauncherThread.runningOnLauncherThread(); |
| 58 return new ChildProcessLauncherHelper( | 58 return new ChildProcessLauncherHelper(nativePointer, paramId, commandLin
e, filesToBeMapped); |
| 59 nativePointer, paramId, commandLine, childProcessId, filesToBeMa
pped); | |
| 60 } | 59 } |
| 61 | 60 |
| 62 private ChildProcessLauncherHelper(long nativePointer, int paramId, final St
ring[] commandLine, | 61 private ChildProcessLauncherHelper(long nativePointer, int paramId, final St
ring[] commandLine, |
| 63 int childProcessId, FileDescriptorInfo[] filesToBeMapped) { | 62 FileDescriptorInfo[] filesToBeMapped) { |
| 64 assert LauncherThread.runningOnLauncherThread(); | 63 assert LauncherThread.runningOnLauncherThread(); |
| 65 mNativeChildProcessLauncherHelper = nativePointer; | 64 mNativeChildProcessLauncherHelper = nativePointer; |
| 66 | 65 |
| 67 ChildProcessLauncher.start(ContextUtils.getApplicationContext(), paramId
, commandLine, | 66 ChildProcessLauncher.start(ContextUtils.getApplicationContext(), paramId
, commandLine, |
| 68 childProcessId, filesToBeMapped, new ChildProcessLauncher.Launch
Callback() { | 67 filesToBeMapped, new ChildProcessLauncher.LaunchCallback() { |
| 69 @Override | 68 @Override |
| 70 public void onChildProcessStarted(BaseChildProcessConnection
connection) { | 69 public void onChildProcessStarted(BaseChildProcessConnection
connection) { |
| 71 mChildProcessConnection = connection; | 70 mChildProcessConnection = connection; |
| 72 if (mNativeChildProcessLauncherHelper != 0) { | 71 if (mNativeChildProcessLauncherHelper != 0) { |
| 73 nativeOnChildProcessStarted( | 72 nativeOnChildProcessStarted( |
| 74 mNativeChildProcessLauncherHelper, getPid())
; | 73 mNativeChildProcessLauncherHelper, getPid())
; |
| 75 } | 74 } |
| 76 mNativeChildProcessLauncherHelper = 0; | 75 mNativeChildProcessLauncherHelper = 0; |
| 77 } | 76 } |
| 78 }); | 77 }); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 // Unittest packages do not declare services. Some tests require a r
ealistic number | 129 // Unittest packages do not declare services. Some tests require a r
ealistic number |
| 131 // to test child process policies, so pick a high-ish number here. | 130 // to test child process policies, so pick a high-ish number here. |
| 132 return 65535; | 131 return 65535; |
| 133 } | 132 } |
| 134 } | 133 } |
| 135 | 134 |
| 136 // Can be called on a number of threads, including launcher, and binder. | 135 // Can be called on a number of threads, including launcher, and binder. |
| 137 private static native void nativeOnChildProcessStarted( | 136 private static native void nativeOnChildProcessStarted( |
| 138 long nativeChildProcessLauncherHelper, int pid); | 137 long nativeChildProcessLauncherHelper, int pid); |
| 139 } | 138 } |
| OLD | NEW |