| 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 .registerRendererProcessHistogram(requestedSharedRel
ro, | 254 .registerRendererProcessHistogram(requestedSharedRel
ro, |
| 255 loadAtFixedAddressFailed); | 255 loadAtFixedAddressFailed); |
| 256 LibraryLoader.get(mLibraryProcessType).initialize(); | 256 LibraryLoader.get(mLibraryProcessType).initialize(); |
| 257 synchronized (mMainThread) { | 257 synchronized (mMainThread) { |
| 258 mLibraryInitialized = true; | 258 mLibraryInitialized = true; |
| 259 mMainThread.notifyAll(); | 259 mMainThread.notifyAll(); |
| 260 while (mFdInfos == null) { | 260 while (mFdInfos == null) { |
| 261 mMainThread.wait(); | 261 mMainThread.wait(); |
| 262 } | 262 } |
| 263 } | 263 } |
| 264 for (FileDescriptorInfo fdInfo : mFdInfos) { | 264 |
| 265 nativeRegisterGlobalFileDescriptor( | 265 int[] fileIds = new int[mFdInfos.length]; |
| 266 fdInfo.mId, fdInfo.mFd.detachFd(), fdInfo.mOffse
t, fdInfo.mSize); | 266 int[] fds = new int[mFdInfos.length]; |
| 267 long[] regionOffsets = new long[mFdInfos.length]; |
| 268 long[] regionSizes = new long[mFdInfos.length]; |
| 269 for (int i = 0; i < mFdInfos.length; i++) { |
| 270 FileDescriptorInfo fdInfo = mFdInfos[i]; |
| 271 fileIds[i] = fdInfo.mId; |
| 272 fds[i] = fdInfo.mFd.detachFd(); |
| 273 regionOffsets[i] = fdInfo.mOffset; |
| 274 regionSizes[i] = fdInfo.mSize; |
| 267 } | 275 } |
| 276 nativeRegisterFileDescriptors(fileIds, fds, regionOffsets, r
egionSizes); |
| 268 nativeInitChildProcessImpl(ChildProcessServiceImpl.this, mCp
uCount, | 277 nativeInitChildProcessImpl(ChildProcessServiceImpl.this, mCp
uCount, |
| 269 mCpuFeatures); | 278 mCpuFeatures); |
| 270 if (mActivitySemaphore.tryAcquire()) { | 279 if (mActivitySemaphore.tryAcquire()) { |
| 271 ContentMain.start(); | 280 ContentMain.start(); |
| 272 nativeExitChildProcess(); | 281 nativeExitChildProcess(); |
| 273 } | 282 } |
| 274 } catch (InterruptedException e) { | 283 } catch (InterruptedException e) { |
| 275 Log.w(TAG, "%s startup failed: %s", MAIN_THREAD_NAME, e); | 284 Log.w(TAG, "%s startup failed: %s", MAIN_THREAD_NAME, e); |
| 276 } catch (ProcessInitException e) { | 285 } catch (ProcessInitException e) { |
| 277 Log.w(TAG, "%s startup failed: %s", MAIN_THREAD_NAME, e); | 286 Log.w(TAG, "%s startup failed: %s", MAIN_THREAD_NAME, e); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 try { | 404 try { |
| 396 SurfaceWrapper wrapper = mCallback.getViewSurface(surfaceId); | 405 SurfaceWrapper wrapper = mCallback.getViewSurface(surfaceId); |
| 397 return wrapper != null ? wrapper.getSurface() : null; | 406 return wrapper != null ? wrapper.getSurface() : null; |
| 398 } catch (RemoteException e) { | 407 } catch (RemoteException e) { |
| 399 Log.e(TAG, "Unable to call getViewSurface: %s", e); | 408 Log.e(TAG, "Unable to call getViewSurface: %s", e); |
| 400 return null; | 409 return null; |
| 401 } | 410 } |
| 402 } | 411 } |
| 403 | 412 |
| 404 /** | 413 /** |
| 405 * Helper for registering FileDescriptorInfo objects with GlobalFileDescript
ors. | 414 * Helper for registering FileDescriptorInfo objects with GlobalFileDescript
ors or |
| 415 * FileDescriptorStore. |
| 406 * This includes the IPC channel, the crash dump signals and resource relate
d | 416 * This includes the IPC channel, the crash dump signals and resource relate
d |
| 407 * files. | 417 * files. |
| 408 */ | 418 */ |
| 409 private static native void nativeRegisterGlobalFileDescriptor( | 419 private static native void nativeRegisterFileDescriptors( |
| 410 int id, int fd, long offset, long size); | 420 int[] id, int[] fd, long[] offset, long[] size); |
| 411 | 421 |
| 412 /** | 422 /** |
| 413 * The main entry point for a child process. This should be called from a ne
w thread since | 423 * The main entry point for a child process. This should be called from a ne
w thread since |
| 414 * it will not return until the child process exits. See child_process_servi
ce.{h,cc} | 424 * it will not return until the child process exits. See child_process_servi
ce.{h,cc} |
| 415 * | 425 * |
| 416 * @param serviceImpl The current ChildProcessServiceImpl object. | 426 * @param serviceImpl The current ChildProcessServiceImpl object. |
| 417 * renderer. | 427 * renderer. |
| 418 */ | 428 */ |
| 419 private static native void nativeInitChildProcessImpl( | 429 private static native void nativeInitChildProcessImpl( |
| 420 ChildProcessServiceImpl serviceImpl, int cpuCount, long cpuFeatures)
; | 430 ChildProcessServiceImpl serviceImpl, int cpuCount, long cpuFeatures)
; |
| 421 | 431 |
| 422 /** | 432 /** |
| 423 * Force the child process to exit. | 433 * Force the child process to exit. |
| 424 */ | 434 */ |
| 425 private static native void nativeExitChildProcess(); | 435 private static native void nativeExitChildProcess(); |
| 426 | 436 |
| 427 private native void nativeShutdownMainThread(); | 437 private native void nativeShutdownMainThread(); |
| 428 } | 438 } |
| OLD | NEW |