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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
253 .registerRendererProcessHistogram(requestedSharedRel ro, | 253 .registerRendererProcessHistogram(requestedSharedRel ro, |
254 loadAtFixedAddressFailed); | 254 loadAtFixedAddressFailed); |
255 LibraryLoader.get(mLibraryProcessType).initialize(); | 255 LibraryLoader.get(mLibraryProcessType).initialize(); |
256 synchronized (mMainThread) { | 256 synchronized (mMainThread) { |
257 mLibraryInitialized = true; | 257 mLibraryInitialized = true; |
258 mMainThread.notifyAll(); | 258 mMainThread.notifyAll(); |
259 while (mFdInfos == null) { | 259 while (mFdInfos == null) { |
260 mMainThread.wait(); | 260 mMainThread.wait(); |
261 } | 261 } |
262 } | 262 } |
263 | |
264 String sharedFilesValue = CommandLine.getInstance().getSwitc hValue( | |
265 ContentSwitches.SHARED_FILES, null); | |
266 long storeRegistrationContext = | |
267 nativeCreateFileDescriptorStoreRegistrationContext(s haredFilesValue); | |
263 for (FileDescriptorInfo fdInfo : mFdInfos) { | 268 for (FileDescriptorInfo fdInfo : mFdInfos) { |
264 nativeRegisterGlobalFileDescriptor( | 269 // For now we support the FileDescriptorStore (which pas ses string keys for |
265 fdInfo.mId, fdInfo.mFd.detachFd(), fdInfo.mOffse t, fdInfo.mSize); | 270 // FDs through the command line) and the GlobalFileDescr iptor (which uses |
271 // int keys). | |
272 int fd = fdInfo.mFd.detachFd(); | |
273 if (storeRegistrationContext == 0 | |
274 || !nativeRegisterInFileDescriptorStore(storeReg istrationContext, | |
275 fdInfo.mId, fd, fdInfo.mOffset, fdInf o.mSize)) { | |
276 nativeRegisterGlobalFileDescriptor( | |
boliu
2017/02/09 23:59:55
that's a lot of jni calls
just put these things i
Jay Civelli
2017/02/10 06:32:34
Merged it all in one JNI call.
| |
277 fdInfo.mId, fd, fdInfo.mOffset, fdInfo.mSize ); | |
278 } | |
266 } | 279 } |
280 nativeReleaseFileDescriptorStoreRegistrationContext(storeReg istrationContext); | |
267 nativeInitChildProcessImpl(ChildProcessServiceImpl.this, mCp uCount, | 281 nativeInitChildProcessImpl(ChildProcessServiceImpl.this, mCp uCount, |
268 mCpuFeatures); | 282 mCpuFeatures); |
269 if (mActivitySemaphore.tryAcquire()) { | 283 if (mActivitySemaphore.tryAcquire()) { |
270 ContentMain.start(); | 284 ContentMain.start(); |
271 nativeExitChildProcess(); | 285 nativeExitChildProcess(); |
272 } | 286 } |
273 } catch (InterruptedException e) { | 287 } catch (InterruptedException e) { |
274 Log.w(TAG, "%s startup failed: %s", MAIN_THREAD_NAME, e); | 288 Log.w(TAG, "%s startup failed: %s", MAIN_THREAD_NAME, e); |
275 } catch (ProcessInitException e) { | 289 } catch (ProcessInitException e) { |
276 Log.w(TAG, "%s startup failed: %s", MAIN_THREAD_NAME, e); | 290 Log.w(TAG, "%s startup failed: %s", MAIN_THREAD_NAME, e); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
394 try { | 408 try { |
395 SurfaceWrapper wrapper = mCallback.getViewSurface(surfaceId); | 409 SurfaceWrapper wrapper = mCallback.getViewSurface(surfaceId); |
396 return wrapper != null ? wrapper.getSurface() : null; | 410 return wrapper != null ? wrapper.getSurface() : null; |
397 } catch (RemoteException e) { | 411 } catch (RemoteException e) { |
398 Log.e(TAG, "Unable to call getViewSurface: %s", e); | 412 Log.e(TAG, "Unable to call getViewSurface: %s", e); |
399 return null; | 413 return null; |
400 } | 414 } |
401 } | 415 } |
402 | 416 |
403 /** | 417 /** |
418 * Creates/releases a context needed by nativeRegisterInFileDescriptorStore. | |
419 */ | |
420 private static native long nativeCreateFileDescriptorStoreRegistrationContex t( | |
421 String sharedFileSwitchValue); | |
422 private static native void nativeReleaseFileDescriptorStoreRegistrationConte xt(long context); | |
423 | |
424 /** | |
425 * Helper for registering FileDescriptorInfo objects with FileDescriptorStor e. | |
426 * Returns true if the file was registered (if it was found in the command l ine). | |
427 */ | |
428 private static native boolean nativeRegisterInFileDescriptorStore( | |
429 long context, int id, int fd, long offset, long size); | |
430 | |
431 /** | |
404 * Helper for registering FileDescriptorInfo objects with GlobalFileDescript ors. | 432 * Helper for registering FileDescriptorInfo objects with GlobalFileDescript ors. |
405 * This includes the IPC channel, the crash dump signals and resource relate d | 433 * This includes the IPC channel, the crash dump signals and resource relate d |
406 * files. | 434 * files. |
407 */ | 435 */ |
408 private static native void nativeRegisterGlobalFileDescriptor( | 436 private static native void nativeRegisterGlobalFileDescriptor( |
409 int id, int fd, long offset, long size); | 437 int id, int fd, long offset, long size); |
410 | 438 |
411 /** | 439 /** |
412 * The main entry point for a child process. This should be called from a ne w thread since | 440 * The main entry point for a child process. This should be called from a ne w thread since |
413 * it will not return until the child process exits. See child_process_servi ce.{h,cc} | 441 * it will not return until the child process exits. See child_process_servi ce.{h,cc} |
414 * | 442 * |
415 * @param serviceImpl The current ChildProcessServiceImpl object. | 443 * @param serviceImpl The current ChildProcessServiceImpl object. |
416 * renderer. | 444 * renderer. |
417 */ | 445 */ |
418 private static native void nativeInitChildProcessImpl( | 446 private static native void nativeInitChildProcessImpl( |
419 ChildProcessServiceImpl serviceImpl, int cpuCount, long cpuFeatures) ; | 447 ChildProcessServiceImpl serviceImpl, int cpuCount, long cpuFeatures) ; |
420 | 448 |
421 /** | 449 /** |
422 * Force the child process to exit. | 450 * Force the child process to exit. |
423 */ | 451 */ |
424 private static native void nativeExitChildProcess(); | 452 private static native void nativeExitChildProcess(); |
425 | 453 |
426 private native void nativeShutdownMainThread(); | 454 private native void nativeShutdownMainThread(); |
427 } | 455 } |
OLD | NEW |