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

Side by Side Diff: content/public/android/java/src/org/chromium/content/browser/ChildProcessLauncher.java

Issue 2076583002: Add WebAPK's tests in ChildProcessLauncherTest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move more functions to the helper class. Created 4 years, 6 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 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 924 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 } 935 }
936 936
937 static void logPidWarning(int pid, String message) { 937 static void logPidWarning(int pid, String message) {
938 // This class is effectively a no-op in single process mode, so don't lo g warnings there. 938 // This class is effectively a no-op in single process mode, so don't lo g warnings there.
939 if (pid > 0 && !nativeIsSingleProcess()) { 939 if (pid > 0 && !nativeIsSingleProcess()) {
940 Log.w(TAG, "%s, pid=%d", message, pid); 940 Log.w(TAG, "%s, pid=%d", message, pid);
941 } 941 }
942 } 942 }
943 943
944 @VisibleForTesting 944 @VisibleForTesting
945 static ChildProcessConnection allocateBoundConnectionForTesting(Context cont ext, 945 public static ChildProcessConnection allocateBoundConnectionForTesting(Conte xt context,
no sievers 2016/06/23 17:20:15 Can we maybe expose this through the test helper i
Xi Han 2016/06/23 18:47:04 We could, but we have to declare the private alloc
no sievers 2016/06/23 20:19:32 But CPLTestHelper is in the same package. On seco
946 ChildProcessCreationParams creationParams) { 946 ChildProcessCreationParams creationParams) {
947 return allocateBoundConnection(context, null, true, false, creationParam s); 947 return allocateBoundConnection(context, null, true, false, creationParam s);
948 } 948 }
949 949
950 /** 950 /**
951 * Queue up a spawn requests for testing. 951 * Queue up a spawn requests for testing.
952 */ 952 */
953 @VisibleForTesting 953 @VisibleForTesting
954 static void enqueuePendingSpawnForTesting(Context context, String[] commandL ine, 954 static void enqueuePendingSpawnForTesting(Context context, String[] commandL ine,
955 ChildProcessCreationParams creationParams, boolean inSandbox) { 955 ChildProcessCreationParams creationParams, boolean inSandbox) {
956 String packageName = creationParams != null ? creationParams.getPackageN ame() 956 String packageName = creationParams != null ? creationParams.getPackageN ame()
957 : context.getPackageName(); 957 : context.getPackageName();
958 PendingSpawnQueue pendingSpawnQueue = getPendingSpawnQueue(context, 958 PendingSpawnQueue pendingSpawnQueue = getPendingSpawnQueue(context,
959 packageName, inSandbox); 959 packageName, inSandbox);
960 synchronized (pendingSpawnQueue.mPendingSpawnsLock) { 960 synchronized (pendingSpawnQueue.mPendingSpawnsLock) {
961 pendingSpawnQueue.enqueueLocked(new PendingSpawnData(context, comman dLine, 1, 961 pendingSpawnQueue.enqueueLocked(new PendingSpawnData(context, comman dLine, 1,
962 new FileDescriptorInfo[0], 0, CALLBACK_FOR_RENDERER_PROCESS, true, 962 new FileDescriptorInfo[0], 0, CALLBACK_FOR_RENDERER_PROCESS, true,
963 creationParams)); 963 creationParams));
964 } 964 }
965 } 965 }
966 966
967 /** 967 /**
968 * @return the number of sandboxed connections of given {@link packageName} managed by the 968 * @return the number of sandboxed connections of given {@link packageName} managed by the
969 * allocator. 969 * allocator.
970 */ 970 */
971 @VisibleForTesting 971 @VisibleForTesting
972 static int allocatedSandboxedConnectionsCountForTesting(Context context, Str ing packageName) { 972 public static int allocatedSandboxedConnectionsCountForTesting(Context conte xt,
973 String packageName) {
973 initConnectionAllocatorsIfNecessary(context, true, packageName); 974 initConnectionAllocatorsIfNecessary(context, true, packageName);
974 return sSandboxedChildConnectionAllocatorMap.get(packageName) 975 return sSandboxedChildConnectionAllocatorMap.get(packageName)
975 .allocatedConnectionsCountForTesting(); 976 .allocatedConnectionsCountForTesting();
976 } 977 }
977 978
978 /** @return the count of services set up and working */ 979 /** @return the count of services set up and working */
979 @VisibleForTesting 980 @VisibleForTesting
980 static int connectedServicesCountForTesting() { 981 static int connectedServicesCountForTesting() {
981 return sServiceMap.size(); 982 return sServiceMap.size();
982 } 983 }
(...skipping 28 matching lines...) Expand all
1011 } 1012 }
1012 1013
1013 return true; 1014 return true;
1014 } 1015 }
1015 1016
1016 private static native void nativeOnChildProcessStarted(long clientContext, i nt pid); 1017 private static native void nativeOnChildProcessStarted(long clientContext, i nt pid);
1017 private static native void nativeEstablishSurfacePeer( 1018 private static native void nativeEstablishSurfacePeer(
1018 int pid, Surface surface, int primaryID, int secondaryID); 1019 int pid, Surface surface, int primaryID, int secondaryID);
1019 private static native boolean nativeIsSingleProcess(); 1020 private static native boolean nativeIsSingleProcess();
1020 } 1021 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698