| 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.browser; | 5 package org.chromium.content.browser; |
| 6 | 6 |
| 7 import android.content.Intent; | 7 import android.content.Intent; |
| 8 import android.util.SparseArray; | 8 import android.util.SparseArray; |
| 9 | 9 |
| 10 import org.chromium.base.library_loader.LibraryProcessType; | 10 import org.chromium.base.library_loader.LibraryProcessType; |
| 11 | 11 |
| 12 /** | 12 /** |
| 13 * Allows specifying the package name for looking up child services | 13 * Allows specifying the package name for looking up child services |
| 14 * configuration and classes into (if it differs from the application | 14 * configuration and classes into (if it differs from the application |
| 15 * package name, like in the case of Android WebView). Also allows | 15 * package name, like in the case of Android WebView). Also allows |
| 16 * specifying additional child service binging flags. | 16 * specifying additional child service binding flags. |
| 17 */ | 17 */ |
| 18 public class ChildProcessCreationParams { | 18 public class ChildProcessCreationParams { |
| 19 private static final String EXTRA_LIBRARY_PROCESS_TYPE = | |
| 20 "org.chromium.content.common.child_service_params.library_process_ty
pe"; | |
| 21 | |
| 22 /** ID used for the default params. */ | 19 /** ID used for the default params. */ |
| 23 public static final int DEFAULT_ID = 0; | 20 public static final int DEFAULT_ID = 0; |
| 24 | 21 |
| 25 private static final Object sLock = new Object(); | 22 private static final Object sLock = new Object(); |
| 26 private static final SparseArray<ChildProcessCreationParams> sParamMap = new
SparseArray<>(); | 23 private static final SparseArray<ChildProcessCreationParams> sParamMap = new
SparseArray<>(); |
| 27 private static int sNextId = 1; // 0 is reserved for DEFAULT_ID. | 24 private static int sNextId = 1; // 0 is reserved for DEFAULT_ID. |
| 28 | 25 |
| 29 /** Register default params. This should be called once on start up. */ | 26 /** Register default params. This should be called once on start up. */ |
| 30 public static void registerDefault(ChildProcessCreationParams params) { | 27 public static void registerDefault(ChildProcessCreationParams params) { |
| 31 synchronized (sLock) { | 28 synchronized (sLock) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 81 |
| 85 boolean getIsExternalService() { | 82 boolean getIsExternalService() { |
| 86 return mIsExternalService; | 83 return mIsExternalService; |
| 87 } | 84 } |
| 88 | 85 |
| 89 int getLibraryProcessType() { | 86 int getLibraryProcessType() { |
| 90 return mLibraryProcessType; | 87 return mLibraryProcessType; |
| 91 } | 88 } |
| 92 | 89 |
| 93 void addIntentExtras(Intent intent) { | 90 void addIntentExtras(Intent intent) { |
| 94 intent.putExtra(EXTRA_LIBRARY_PROCESS_TYPE, mLibraryProcessType); | 91 intent.putExtra(ChildProcessConstants.EXTRA_LIBRARY_PROCESS_TYPE, mLibra
ryProcessType); |
| 95 } | 92 } |
| 96 | 93 |
| 97 public static int getLibraryProcessType(Intent intent) { | 94 public static int getLibraryProcessType(Intent intent) { |
| 98 return intent.getIntExtra(EXTRA_LIBRARY_PROCESS_TYPE, | 95 return intent.getIntExtra( |
| 99 LibraryProcessType.PROCESS_CHILD); | 96 ChildProcessConstants.EXTRA_LIBRARY_PROCESS_TYPE, LibraryProcess
Type.PROCESS_CHILD); |
| 100 } | 97 } |
| 101 } | 98 } |
| OLD | NEW |