| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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.app; | 5 package org.chromium.content.app; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.content.Intent; | 8 import android.content.Intent; |
| 9 import android.graphics.SurfaceTexture; | 9 import android.graphics.SurfaceTexture; |
| 10 import android.os.Binder; | 10 import android.os.Binder; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 private String[] mCommandLineParams; | 58 private String[] mCommandLineParams; |
| 59 private int mCpuCount; | 59 private int mCpuCount; |
| 60 private long mCpuFeatures; | 60 private long mCpuFeatures; |
| 61 // File descriptors that should be registered natively. | 61 // File descriptors that should be registered natively. |
| 62 private FileDescriptorInfo[] mFdInfos; | 62 private FileDescriptorInfo[] mFdInfos; |
| 63 // Linker-specific parameters for this child process service. | 63 // Linker-specific parameters for this child process service. |
| 64 private ChromiumLinkerParams mLinkerParams; | 64 private ChromiumLinkerParams mLinkerParams; |
| 65 // Child library process type. | 65 // Child library process type. |
| 66 private int mLibraryProcessType; | 66 private int mLibraryProcessType; |
| 67 | 67 |
| 68 private static AtomicReference<Context> sContext = new AtomicReference<Conte
xt>(null); | 68 private static AtomicReference<Context> sContext = new AtomicReference<>(nul
l); |
| 69 private boolean mLibraryInitialized = false; | 69 private boolean mLibraryInitialized = false; |
| 70 // Becomes true once the service is bound. Access must synchronize around mM
ainThread. | 70 // Becomes true once the service is bound. Access must synchronize around mM
ainThread. |
| 71 private boolean mIsBound = false; | 71 private boolean mIsBound = false; |
| 72 | 72 |
| 73 /** | 73 /** |
| 74 * If >= 0 enables "validation of caller of {@link mBinder}'s methods". A Re
moteException | 74 * If >= 0 enables "validation of caller of {@link mBinder}'s methods". A Re
moteException |
| 75 * is thrown when an application with a uid other than {@link mAuthorizedCal
lerUid} calls | 75 * is thrown when an application with a uid other than {@link mAuthorizedCal
lerUid} calls |
| 76 * {@link mBinder}'s methods. | 76 * {@link mBinder}'s methods. |
| 77 */ | 77 */ |
| 78 private int mAuthorizedCallerUid; | 78 private int mAuthorizedCallerUid; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 // The ClassLoader for the host browser context. | 124 // The ClassLoader for the host browser context. |
| 125 private ClassLoader mHostClassLoader; | 125 private ClassLoader mHostClassLoader; |
| 126 | 126 |
| 127 /* package */ static Context getContext() { | 127 /* package */ static Context getContext() { |
| 128 return sContext.get(); | 128 return sContext.get(); |
| 129 } | 129 } |
| 130 | 130 |
| 131 /** | 131 /** |
| 132 * Loads Chrome's native libraries and initializes a ChildProcessServiceImpl
. | 132 * Loads Chrome's native libraries and initializes a ChildProcessServiceImpl
. |
| 133 * @param context The application context. | 133 * @param context The application context. |
| 134 * @param hostBrowserContext The context of the host browser (i.e. Chrome). | 134 * @param hostContext The context of the host browser (i.e. Chrome). |
| 135 */ | 135 */ |
| 136 public void create(final Context context, final Context hostBrowserContext)
{ | 136 public void create(final Context context, final Context hostContext) { |
| 137 mHostClassLoader = hostBrowserContext.getClassLoader(); | 137 mHostClassLoader = hostContext.getClassLoader(); |
| 138 Log.i(TAG, "Creating new ChildProcessService pid=%d", Process.myPid()); | 138 Log.i(TAG, "Creating new ChildProcessService pid=%d", Process.myPid()); |
| 139 if (sContext.get() != null) { | 139 if (sContext.get() != null) { |
| 140 throw new RuntimeException("Illegal child process reuse."); | 140 throw new RuntimeException("Illegal child process reuse."); |
| 141 } | 141 } |
| 142 sContext.set(context); | 142 sContext.set(context); |
| 143 | 143 |
| 144 // Initialize the context for the application that owns this ChildProces
sServiceImpl object. | 144 // Initialize the context for the application that owns this ChildProces
sServiceImpl object. |
| 145 ContextUtils.initApplicationContext(context); | 145 ContextUtils.initApplicationContext(context); |
| 146 | 146 |
| 147 mMainThread = new Thread(new Runnable() { | 147 mMainThread = new Thread(new Runnable() { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 174 } | 174 } |
| 175 } | 175 } |
| 176 boolean isLoaded = false; | 176 boolean isLoaded = false; |
| 177 if (CommandLine.getInstance().hasSwitch( | 177 if (CommandLine.getInstance().hasSwitch( |
| 178 BaseSwitches.RENDERER_WAIT_FOR_JAVA_DEBUGGER)) { | 178 BaseSwitches.RENDERER_WAIT_FOR_JAVA_DEBUGGER)) { |
| 179 android.os.Debug.waitForDebugger(); | 179 android.os.Debug.waitForDebugger(); |
| 180 } | 180 } |
| 181 | 181 |
| 182 boolean loadAtFixedAddressFailed = false; | 182 boolean loadAtFixedAddressFailed = false; |
| 183 try { | 183 try { |
| 184 LibraryLoader.get(mLibraryProcessType).loadNow(hostBrows
erContext); | 184 LibraryLoader.get(mLibraryProcessType).loadNow(hostConte
xt); |
| 185 isLoaded = true; | 185 isLoaded = true; |
| 186 } catch (ProcessInitException e) { | 186 } catch (ProcessInitException e) { |
| 187 if (requestedSharedRelro) { | 187 if (requestedSharedRelro) { |
| 188 Log.w(TAG, "Failed to load native library with share
d RELRO, " | 188 Log.w(TAG, "Failed to load native library with share
d RELRO, " |
| 189 + "retrying without"); | 189 + "retrying without"); |
| 190 loadAtFixedAddressFailed = true; | 190 loadAtFixedAddressFailed = true; |
| 191 } else { | 191 } else { |
| 192 Log.e(TAG, "Failed to load native library", e); | 192 Log.e(TAG, "Failed to load native library", e); |
| 193 } | 193 } |
| 194 } | 194 } |
| 195 if (!isLoaded && requestedSharedRelro) { | 195 if (!isLoaded && requestedSharedRelro) { |
| 196 linker.disableSharedRelros(); | 196 linker.disableSharedRelros(); |
| 197 try { | 197 try { |
| 198 LibraryLoader.get(mLibraryProcessType).loadNow(hostB
rowserContext); | 198 LibraryLoader.get(mLibraryProcessType).loadNow(hostC
ontext); |
| 199 isLoaded = true; | 199 isLoaded = true; |
| 200 } catch (ProcessInitException e) { | 200 } catch (ProcessInitException e) { |
| 201 Log.e(TAG, "Failed to load native library on retry",
e); | 201 Log.e(TAG, "Failed to load native library on retry",
e); |
| 202 } | 202 } |
| 203 } | 203 } |
| 204 if (!isLoaded) { | 204 if (!isLoaded) { |
| 205 System.exit(-1); | 205 System.exit(-1); |
| 206 } | 206 } |
| 207 LibraryLoader.get(mLibraryProcessType) | 207 LibraryLoader.get(mLibraryProcessType) |
| 208 .registerRendererProcessHistogram(requestedSharedRel
ro, | 208 .registerRendererProcessHistogram(requestedSharedRel
ro, |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 private static native void nativeInitChildProcessImpl( | 472 private static native void nativeInitChildProcessImpl( |
| 473 ChildProcessServiceImpl serviceImpl, int cpuCount, long cpuFeatures)
; | 473 ChildProcessServiceImpl serviceImpl, int cpuCount, long cpuFeatures)
; |
| 474 | 474 |
| 475 /** | 475 /** |
| 476 * Force the child process to exit. | 476 * Force the child process to exit. |
| 477 */ | 477 */ |
| 478 private static native void nativeExitChildProcess(); | 478 private static native void nativeExitChildProcess(); |
| 479 | 479 |
| 480 private native void nativeShutdownMainThread(); | 480 private native void nativeShutdownMainThread(); |
| 481 } | 481 } |
| OLD | NEW |