Chromium Code Reviews| 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). |
|
Ted C
2016/09/28 17:27:46
I would drop browser from the comment as well.
I
Peter Wen
2016/09/29 18:41:38
Done.
| |
| 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) |
| 185 .loadNowOverrideApplicationContext(hostContext); | |
| 185 isLoaded = true; | 186 isLoaded = true; |
| 186 } catch (ProcessInitException e) { | 187 } catch (ProcessInitException e) { |
| 187 if (requestedSharedRelro) { | 188 if (requestedSharedRelro) { |
| 188 Log.w(TAG, "Failed to load native library with share d RELRO, " | 189 Log.w(TAG, "Failed to load native library with share d RELRO, " |
| 189 + "retrying without"); | 190 + "retrying without"); |
| 190 loadAtFixedAddressFailed = true; | 191 loadAtFixedAddressFailed = true; |
| 191 } else { | 192 } else { |
| 192 Log.e(TAG, "Failed to load native library", e); | 193 Log.e(TAG, "Failed to load native library", e); |
| 193 } | 194 } |
| 194 } | 195 } |
| 195 if (!isLoaded && requestedSharedRelro) { | 196 if (!isLoaded && requestedSharedRelro) { |
| 196 linker.disableSharedRelros(); | 197 linker.disableSharedRelros(); |
| 197 try { | 198 try { |
| 198 LibraryLoader.get(mLibraryProcessType).loadNow(hostB rowserContext); | 199 LibraryLoader.get(mLibraryProcessType) |
| 200 .loadNowOverrideApplicationContext(hostConte xt); | |
| 199 isLoaded = true; | 201 isLoaded = true; |
| 200 } catch (ProcessInitException e) { | 202 } catch (ProcessInitException e) { |
| 201 Log.e(TAG, "Failed to load native library on retry", e); | 203 Log.e(TAG, "Failed to load native library on retry", e); |
| 202 } | 204 } |
| 203 } | 205 } |
| 204 if (!isLoaded) { | 206 if (!isLoaded) { |
| 205 System.exit(-1); | 207 System.exit(-1); |
| 206 } | 208 } |
| 207 LibraryLoader.get(mLibraryProcessType) | 209 LibraryLoader.get(mLibraryProcessType) |
| 208 .registerRendererProcessHistogram(requestedSharedRel ro, | 210 .registerRendererProcessHistogram(requestedSharedRel ro, |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 472 private static native void nativeInitChildProcessImpl( | 474 private static native void nativeInitChildProcessImpl( |
| 473 ChildProcessServiceImpl serviceImpl, int cpuCount, long cpuFeatures) ; | 475 ChildProcessServiceImpl serviceImpl, int cpuCount, long cpuFeatures) ; |
| 474 | 476 |
| 475 /** | 477 /** |
| 476 * Force the child process to exit. | 478 * Force the child process to exit. |
| 477 */ | 479 */ |
| 478 private static native void nativeExitChildProcess(); | 480 private static native void nativeExitChildProcess(); |
| 479 | 481 |
| 480 private native void nativeShutdownMainThread(); | 482 private native void nativeShutdownMainThread(); |
| 481 } | 483 } |
| OLD | NEW |