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

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

Issue 2843853002: Making BindingManager work on the launcher thread only. (Closed)
Patch Set: Added a comment. Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: content/public/android/java/src/org/chromium/content/browser/ChildProcessLauncher.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/ChildProcessLauncher.java b/content/public/android/java/src/org/chromium/content/browser/ChildProcessLauncher.java
index 611e2a1b81c96f222f83cac1d53ba8f24162b86b..df636694f45b4e868dcf8bf803d67968f1a5375b 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ChildProcessLauncher.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ChildProcessLauncher.java
@@ -222,40 +222,42 @@ public class ChildProcessLauncher {
* Called when the renderer commits a navigation. This signals a time at which it is safe to
* rely on renderer visibility signalled through setInForeground. See http://crbug.com/421041.
*/
- public static void determinedVisibility(int pid) {
- getBindingManager().determinedVisibility(pid);
+ public static void determinedVisibility(final int pid) {
+ assert ThreadUtils.runningOnUiThread();
+ LauncherThread.post(new Runnable() {
+ @Override
+ public void run() {
+ getBindingManager().onDeterminedVisibility(pid);
+ }
+ });
}
/**
* Called when the embedding application is sent to background.
*/
public static void onSentToBackground() {
+ assert ThreadUtils.runningOnUiThread();
sApplicationInForeground = false;
- getBindingManager().onSentToBackground();
- }
-
- /**
- * Starts moderate binding management.
- * Note: WebAPKs and non WebAPKs share the same moderate binding pool, so the size of the
- * shared moderate binding pool is always set based on the number of sandboxes processes
- * used by Chrome.
- * @param context Android's context.
- * @param moderateBindingTillBackgrounded true if the BindingManager should add a moderate
- * binding to a render process when it is created and remove the moderate binding when Chrome is
- * sent to the background.
- */
- public static void startModerateBindingManagement(Context context) {
- getBindingManager().startModerateBindingManagement(context,
- ChildConnectionAllocator.getNumberOfServices(
- context, true, context.getPackageName()));
+ LauncherThread.post(new Runnable() {
+ @Override
+ public void run() {
+ getBindingManager().onSentToBackground();
+ }
+ });
}
/**
* Called when the embedding application is brought to foreground.
*/
public static void onBroughtToForeground() {
+ assert ThreadUtils.runningOnUiThread();
sApplicationInForeground = true;
- getBindingManager().onBroughtToForeground();
+ LauncherThread.post(new Runnable() {
+ @Override
+ public void run() {
+ getBindingManager().onBroughtToForeground();
+ }
+ });
}
/**
@@ -266,6 +268,28 @@ public class ChildProcessLauncher {
}
/**
+ * Starts moderate binding management.
+ * Note: WebAPKs and non WebAPKs share the same moderate binding pool, so the size of the
+ * shared moderate binding pool is always set based on the number of sandboxes processes
+ * used by Chrome.
+ * @param context Android's context.
+ * @param moderateBindingTillBackgrounded true if the BindingManager should add a moderate
+ * binding to a render process when it is created and remove the moderate binding when Chrome is
+ * sent to the background.
+ */
+ public static void startModerateBindingManagement(final Context context) {
+ assert ThreadUtils.runningOnUiThread();
+ LauncherThread.post(new Runnable() {
+ @Override
+ public void run() {
+ getBindingManager().startModerateBindingManagement(context,
+ ChildConnectionAllocator.getNumberOfServices(
+ context, true, context.getPackageName()));
+ }
+ });
+ }
+
+ /**
* Should be called early in startup so the work needed to spawn the child process can be done
* in parallel to other startup work. Spare connection is created in sandboxed child process.
* @param context the application context used for the connection.
@@ -322,15 +346,14 @@ public class ChildProcessLauncher {
}
/**
- * Spawns and connects to a child process. May be called on any thread. It will not block, but
- * will instead callback to {@link #nativeOnChildProcessStarted} when the connection is
- * established. Note this callback will not necessarily be from the same thread (currently it
- * always comes from the main thread).
+ * Spawns and connects to a child process. It will not block, but will instead callback to
+ * {@link #LaunchCallback} on the launcher thread when the connection is established on.
*
* @param context Context used to obtain the application context.
* @param paramId Key used to retrieve ChildProcessCreationParams.
* @param commandLine The child process command line argv.
* @param filesToBeMapped File IDs, FDs, offsets, and lengths to pass through.
+ * @param launchCallback Callback invoked when the connection is established.
*/
static void start(Context context, int paramId, final String[] commandLine, int childProcessId,
FileDescriptorInfo[] filesToBeMapped, LaunchCallback launchCallback) {
@@ -473,6 +496,7 @@ public class ChildProcessLauncher {
new BaseChildProcessConnection.ConnectionCallback() {
@Override
public void onConnected(BaseChildProcessConnection connection) {
+ assert LauncherThread.runningOnLauncherThread();
if (connection != null) {
int pid = connection.getPid();
Log.d(TAG, "on connect callback, pid=%d", pid);

Powered by Google App Engine
This is Rietveld 408576698