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

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

Issue 2821583002: android: Post stop/onServiceDisconnected to launcher (Closed)
Patch Set: rebase 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/ChildProcessConnectionImpl.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/ChildProcessConnectionImpl.java b/content/public/android/java/src/org/chromium/content/browser/ChildProcessConnectionImpl.java
index de8e0f3457a3c253d069bff721b4721bba40b9df..ecbafeff7589a90e92d9dd9b02755b090328e1ae 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ChildProcessConnectionImpl.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ChildProcessConnectionImpl.java
@@ -16,7 +16,6 @@ import android.os.IBinder;
import android.os.RemoteException;
import org.chromium.base.Log;
-import org.chromium.base.ThreadUtils;
import org.chromium.base.TraceEvent;
import org.chromium.base.VisibleForTesting;
import org.chromium.base.process_launcher.ChildProcessCreationParams;
@@ -218,25 +217,12 @@ public class ChildProcessConnectionImpl implements ChildProcessConnection {
// Called on the main thread to notify that the child service did not disconnect gracefully.
@Override
public void onServiceDisconnected(ComponentName className) {
- synchronized (mLock) {
- // Ensure that the disconnection logic runs only once (instead of once per each
- // ChildServiceConnection).
- if (mServiceDisconnected) {
- return;
- }
- // Stash the status of the oom bindings, since stop() will release all bindings.
- mWasOomProtected = isCurrentlyOomProtected();
- mServiceDisconnected = true;
- Log.w(TAG, "onServiceDisconnected (crash or killed by oom): pid=%d", mPid);
- stop(); // We don't want to auto-restart on crash. Let the browser do that.
- mDeathCallback.onChildProcessDied(ChildProcessConnectionImpl.this);
- // If we have a pending connection callback, we need to communicate the failure to
- // the caller.
- if (mConnectionCallback != null) {
- mConnectionCallback.onConnected(0);
+ LauncherThread.post(new Runnable() {
+ @Override
+ public void run() {
+ ChildProcessConnectionImpl.this.onServiceDisconnectedOnLauncherThread();
}
- mConnectionCallback = null;
- }
+ });
}
}
@@ -329,8 +315,8 @@ public class ChildProcessConnectionImpl implements ChildProcessConnection {
public void start(ChildProcessConnection.StartCallback startCallback) {
try {
TraceEvent.begin("ChildProcessConnectionImpl.start");
+ assert LauncherThread.runningOnLauncherThread();
synchronized (mLock) {
- assert !ThreadUtils.runningOnUiThread();
assert mConnectionParams == null :
"setupConnection() called before start() in ChildProcessConnectionImpl.";
@@ -390,6 +376,29 @@ public class ChildProcessConnectionImpl implements ChildProcessConnection {
}
}
+ private void onServiceDisconnectedOnLauncherThread() {
+ assert LauncherThread.runningOnLauncherThread();
+ synchronized (mLock) {
+ // Ensure that the disconnection logic runs only once (instead of once per each
+ // ChildServiceConnection).
+ if (mServiceDisconnected) {
+ return;
+ }
+ // Stash the status of the oom bindings, since stop() will release all bindings.
+ mWasOomProtected = isCurrentlyOomProtected();
+ mServiceDisconnected = true;
+ Log.w(TAG, "onServiceDisconnected (crash or killed by oom): pid=%d", mPid);
+ stop(); // We don't want to auto-restart on crash. Let the browser do that.
+ mDeathCallback.onChildProcessDied(ChildProcessConnectionImpl.this);
+ // If we have a pending connection callback, we need to communicate the failure to
+ // the caller.
+ if (mConnectionCallback != null) {
+ mConnectionCallback.onConnected(0);
+ }
+ mConnectionCallback = null;
+ }
+ }
+
private void onSetupConnectionResult(int pid) {
synchronized (mLock) {
mPid = pid;

Powered by Google App Engine
This is Rietveld 408576698