OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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.ComponentName; | 7 import android.content.ComponentName; |
8 import android.content.Context; | 8 import android.content.Context; |
9 import android.content.pm.ApplicationInfo; | 9 import android.content.pm.ApplicationInfo; |
10 import android.content.pm.PackageManager; | 10 import android.content.pm.PackageManager; |
11 import android.os.Bundle; | 11 import android.os.Bundle; |
12 import android.text.TextUtils; | 12 import android.text.TextUtils; |
13 | 13 |
14 import org.chromium.base.Log; | 14 import org.chromium.base.Log; |
15 import org.chromium.base.VisibleForTesting; | 15 import org.chromium.base.VisibleForTesting; |
16 import org.chromium.base.annotations.SuppressFBWarnings; | 16 import org.chromium.base.annotations.SuppressFBWarnings; |
| 17 import org.chromium.base.process_launcher.BaseChildProcessConnection; |
| 18 import org.chromium.base.process_launcher.ImportantChildProcessConnection; |
| 19 import org.chromium.base.process_launcher.ManagedChildProcessConnection; |
17 import org.chromium.content.app.PrivilegedProcessService; | 20 import org.chromium.content.app.PrivilegedProcessService; |
18 import org.chromium.content.app.SandboxedProcessService; | 21 import org.chromium.content.app.SandboxedProcessService; |
19 | 22 |
20 import java.util.ArrayList; | 23 import java.util.ArrayList; |
21 import java.util.HashMap; | 24 import java.util.HashMap; |
22 import java.util.LinkedList; | 25 import java.util.LinkedList; |
23 import java.util.Map; | 26 import java.util.Map; |
24 import java.util.Queue; | 27 import java.util.Queue; |
25 | 28 |
26 /** | 29 /** |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 assert spawnData.isInSandbox() == mInSandbox; | 187 assert spawnData.isInSandbox() == mInSandbox; |
185 if (mFreeConnectionIndices.isEmpty()) { | 188 if (mFreeConnectionIndices.isEmpty()) { |
186 Log.d(TAG, "Ran out of services to allocate."); | 189 Log.d(TAG, "Ran out of services to allocate."); |
187 if (queueIfNoSlotAvailable) { | 190 if (queueIfNoSlotAvailable) { |
188 mPendingSpawnQueue.add(spawnData); | 191 mPendingSpawnQueue.add(spawnData); |
189 } | 192 } |
190 return null; | 193 return null; |
191 } | 194 } |
192 int slot = mFreeConnectionIndices.remove(0); | 195 int slot = mFreeConnectionIndices.remove(0); |
193 assert mChildProcessConnections[slot] == null; | 196 assert mChildProcessConnections[slot] == null; |
194 mChildProcessConnections[slot] = mConnectionFactory.create(spawnData.get
Context(), slot, | 197 mChildProcessConnections[slot] = mConnectionFactory.create(LauncherThrea
d.getHandler(), |
195 mInSandbox, deathCallback, mChildClassName, childProcessCommonPa
rameters, | 198 spawnData.getContext(), slot, mInSandbox, deathCallback, mChildC
lassName, |
196 spawnData.getCreationParams()); | 199 childProcessCommonParameters, spawnData.getCreationParams()); |
197 Log.d(TAG, "Allocator allocated a connection, sandbox: %b, slot: %d", mI
nSandbox, slot); | 200 Log.d(TAG, "Allocator allocated a connection, sandbox: %b, slot: %d", mI
nSandbox, slot); |
198 return mChildProcessConnections[slot]; | 201 return mChildProcessConnections[slot]; |
199 } | 202 } |
200 | 203 |
201 // Also return the first ChildSpawnData in the pending queue, if any. | 204 // Also return the first ChildSpawnData in the pending queue, if any. |
202 public ChildSpawnData free(BaseChildProcessConnection connection) { | 205 public ChildSpawnData free(BaseChildProcessConnection connection) { |
203 assert LauncherThread.runningOnLauncherThread(); | 206 assert LauncherThread.runningOnLauncherThread(); |
204 int slot = connection.getServiceNumber(); | 207 int slot = connection.getServiceNumber(); |
205 if (mChildProcessConnections[slot] != connection) { | 208 if (mChildProcessConnections[slot] != connection) { |
206 int occupier = mChildProcessConnections[slot] == null | 209 int occupier = mChildProcessConnections[slot] == null |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 assert LauncherThread.runningOnLauncherThread(); | 245 assert LauncherThread.runningOnLauncherThread(); |
243 mPendingSpawnQueue.add(spawnData); | 246 mPendingSpawnQueue.add(spawnData); |
244 } | 247 } |
245 | 248 |
246 @VisibleForTesting | 249 @VisibleForTesting |
247 int pendingSpawnsCountForTesting() { | 250 int pendingSpawnsCountForTesting() { |
248 assert LauncherThread.runningOnLauncherThread(); | 251 assert LauncherThread.runningOnLauncherThread(); |
249 return mPendingSpawnQueue.size(); | 252 return mPendingSpawnQueue.size(); |
250 } | 253 } |
251 } | 254 } |
OLD | NEW |