Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: content/public/android/java/src/org/chromium/content/app/ChildProcessServiceImpl.java

Issue 2684433003: Files required by a service now listed in manifest. (Closed)
Patch Set: Fixed analysis. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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(
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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 try { 450 try {
437 SurfaceWrapper wrapper = mCallback.getViewSurface(surfaceId); 451 SurfaceWrapper wrapper = mCallback.getViewSurface(surfaceId);
438 return wrapper != null ? wrapper.getSurface() : null; 452 return wrapper != null ? wrapper.getSurface() : null;
439 } catch (RemoteException e) { 453 } catch (RemoteException e) {
440 Log.e(TAG, "Unable to call getViewSurface: %s", e); 454 Log.e(TAG, "Unable to call getViewSurface: %s", e);
441 return null; 455 return null;
442 } 456 }
443 } 457 }
444 458
445 /** 459 /**
460 * Creates/releases a context needed by nativeRegisterInFileDescriptorStore.
461 */
462 private static native long nativeCreateFileDescriptorStoreRegistrationContex t(
463 String sharedFileSwitchValue);
464 private static native void nativeReleaseFileDescriptorStoreRegistrationConte xt(long context);
465
466 /**
467 * Helper for registering FileDescriptorInfo objects with FileDescriptorStor e.
468 * Returns true if the file was registered (if it was found in the command l ine).
469 */
470 private static native boolean nativeRegisterInFileDescriptorStore(
471 long context, int id, int fd, long offset, long size);
472
473 /**
446 * Helper for registering FileDescriptorInfo objects with GlobalFileDescript ors. 474 * Helper for registering FileDescriptorInfo objects with GlobalFileDescript ors.
447 * This includes the IPC channel, the crash dump signals and resource relate d 475 * This includes the IPC channel, the crash dump signals and resource relate d
448 * files. 476 * files.
449 */ 477 */
450 private static native void nativeRegisterGlobalFileDescriptor( 478 private static native void nativeRegisterGlobalFileDescriptor(
451 int id, int fd, long offset, long size); 479 int id, int fd, long offset, long size);
452 480
453 /** 481 /**
454 * The main entry point for a child process. This should be called from a ne w thread since 482 * The main entry point for a child process. This should be called from a ne w thread since
455 * it will not return until the child process exits. See child_process_servi ce.{h,cc} 483 * it will not return until the child process exits. See child_process_servi ce.{h,cc}
456 * 484 *
457 * @param serviceImpl The current ChildProcessServiceImpl object. 485 * @param serviceImpl The current ChildProcessServiceImpl object.
458 * renderer. 486 * renderer.
459 */ 487 */
460 private static native void nativeInitChildProcessImpl( 488 private static native void nativeInitChildProcessImpl(
461 ChildProcessServiceImpl serviceImpl, int cpuCount, long cpuFeatures) ; 489 ChildProcessServiceImpl serviceImpl, int cpuCount, long cpuFeatures) ;
462 490
463 /** 491 /**
464 * Force the child process to exit. 492 * Force the child process to exit.
465 */ 493 */
466 private static native void nativeExitChildProcess(); 494 private static native void nativeExitChildProcess();
467 495
468 private native void nativeShutdownMainThread(); 496 private native void nativeShutdownMainThread();
469 } 497 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698