Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
| 8 import android.app.Service; | 8 import android.app.Service; |
| 9 import android.content.Context; | 9 import android.content.Context; |
| 10 import android.content.Intent; | 10 import android.content.Intent; |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 419 .isFreeConnectionAvailable()) { | 419 .isFreeConnectionAvailable()) { |
| 420 // Proactively releases all the moderate bindings once all the s andboxed services | 420 // Proactively releases all the moderate bindings once all the s andboxed services |
| 421 // are allocated, which will be very likely to have some of them killed by OOM | 421 // are allocated, which will be very likely to have some of them killed by OOM |
| 422 // killer. | 422 // killer. |
| 423 sBindingManager.releaseAllModerateBindings(); | 423 sBindingManager.releaseAllModerateBindings(); |
| 424 } | 424 } |
| 425 } | 425 } |
| 426 return connection; | 426 return connection; |
| 427 } | 427 } |
| 428 | 428 |
| 429 private static ChildProcessConnection allocateConnection(Context context, | |
|
no sievers
2016/06/24 20:04:35
nit: is this function really useful or can it be f
Xi Han
2016/06/24 21:21:31
Done.
| |
| 430 String[] commandLine, boolean inSandbox, boolean alwaysInForeground, | |
| 431 ChildProcessCreationParams creationParams) { | |
| 432 ChromiumLinkerParams chromiumLinkerParams = getLinkerParamsForNewConnect ion(); | |
| 433 return allocateConnection( | |
| 434 context, inSandbox, chromiumLinkerParams, alwaysInForeground, cr eationParams); | |
| 435 } | |
| 436 | |
| 429 private static final long FREE_CONNECTION_DELAY_MILLIS = 1; | 437 private static final long FREE_CONNECTION_DELAY_MILLIS = 1; |
| 430 | 438 |
| 431 private static void freeConnection(ChildProcessConnection connection) { | 439 private static void freeConnection(ChildProcessConnection connection) { |
| 432 synchronized (ChildProcessLauncher.class) { | 440 synchronized (ChildProcessLauncher.class) { |
| 433 if (connection.equals(sSpareSandboxedConnection)) sSpareSandboxedCon nection = null; | 441 if (connection.equals(sSpareSandboxedConnection)) sSpareSandboxedCon nection = null; |
| 434 } | 442 } |
| 435 | 443 |
| 436 // Freeing a service should be delayed. This is so that we avoid immedia tely reusing the | 444 // Freeing a service should be delayed. This is so that we avoid immedia tely reusing the |
| 437 // freed service (see http://crbug.com/164069): the framework might keep a service process | 445 // freed service (see http://crbug.com/164069): the framework might keep a service process |
| 438 // alive when it's been unbound for a short time. If a new connection to the same service | 446 // alive when it's been unbound for a short time. If a new connection to the same service |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 964 Log.w(TAG, "%s, pid=%d", message, pid); | 972 Log.w(TAG, "%s, pid=%d", message, pid); |
| 965 } | 973 } |
| 966 } | 974 } |
| 967 | 975 |
| 968 @VisibleForTesting | 976 @VisibleForTesting |
| 969 static ChildProcessConnection allocateBoundConnectionForTesting(Context cont ext, | 977 static ChildProcessConnection allocateBoundConnectionForTesting(Context cont ext, |
| 970 ChildProcessCreationParams creationParams) { | 978 ChildProcessCreationParams creationParams) { |
| 971 return allocateBoundConnection(context, null, true, false, creationParam s); | 979 return allocateBoundConnection(context, null, true, false, creationParam s); |
| 972 } | 980 } |
| 973 | 981 |
| 982 @VisibleForTesting | |
| 983 static ChildProcessConnection allocateConnectionForTesting(Context context, | |
| 984 ChildProcessCreationParams creationParams) { | |
| 985 return allocateConnection(context, null, true, false, creationParams); | |
| 986 } | |
| 987 | |
| 974 /** | 988 /** |
| 975 * Queue up a spawn requests for testing. | 989 * Queue up a spawn requests for testing. |
| 976 */ | 990 */ |
| 977 @VisibleForTesting | 991 @VisibleForTesting |
| 978 static void enqueuePendingSpawnForTesting(Context context, String[] commandL ine, | 992 static void enqueuePendingSpawnForTesting(Context context, String[] commandL ine, |
| 979 ChildProcessCreationParams creationParams, boolean inSandbox) { | 993 ChildProcessCreationParams creationParams, boolean inSandbox) { |
| 980 String packageName = creationParams != null ? creationParams.getPackageN ame() | 994 String packageName = creationParams != null ? creationParams.getPackageN ame() |
| 981 : context.getPackageName(); | 995 : context.getPackageName(); |
| 982 PendingSpawnQueue pendingSpawnQueue = getPendingSpawnQueue(context, | 996 PendingSpawnQueue pendingSpawnQueue = getPendingSpawnQueue(context, |
| 983 packageName, inSandbox); | 997 packageName, inSandbox); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1035 } | 1049 } |
| 1036 | 1050 |
| 1037 return true; | 1051 return true; |
| 1038 } | 1052 } |
| 1039 | 1053 |
| 1040 private static native void nativeOnChildProcessStarted(long clientContext, i nt pid); | 1054 private static native void nativeOnChildProcessStarted(long clientContext, i nt pid); |
| 1041 private static native void nativeEstablishSurfacePeer( | 1055 private static native void nativeEstablishSurfacePeer( |
| 1042 int pid, Surface surface, int primaryID, int secondaryID); | 1056 int pid, Surface surface, int primaryID, int secondaryID); |
| 1043 private static native boolean nativeIsSingleProcess(); | 1057 private static native boolean nativeIsSingleProcess(); |
| 1044 } | 1058 } |
| OLD | NEW |