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

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

Issue 2810433002: android: Async setupConnection binder call (Closed)
Patch Set: deflake test 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 2ad7b8aeb369b0d06f63816d03cd423df204ecc1..de8e0f3457a3c253d069bff721b4721bba40b9df 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
@@ -21,6 +21,7 @@ import org.chromium.base.TraceEvent;
import org.chromium.base.VisibleForTesting;
import org.chromium.base.process_launcher.ChildProcessCreationParams;
import org.chromium.base.process_launcher.FileDescriptorInfo;
+import org.chromium.base.process_launcher.ICallbackInt;
import org.chromium.base.process_launcher.IChildProcessService;
import java.io.IOException;
@@ -389,6 +390,18 @@ public class ChildProcessConnectionImpl implements ChildProcessConnection {
}
}
+ private void onSetupConnectionResult(int pid) {
+ synchronized (mLock) {
+ mPid = pid;
+ assert mPid != 0 : "Child service claims to be run by a process of pid=0.";
+
+ if (mConnectionCallback != null) {
+ mConnectionCallback.onConnected(mPid);
+ }
+ mConnectionCallback = null;
+ }
+ }
+
/**
* Called after the connection parameters have been set (in setupConnection()) *and* a
* connection has been established (as signaled by onServiceConnected()). These two events can
@@ -402,10 +415,20 @@ public class ChildProcessConnectionImpl implements ChildProcessConnection {
Bundle bundle = ChildProcessLauncher.createsServiceBundle(
mConnectionParams.mCommandLine, mConnectionParams.mFilesToBeMapped);
+ ICallbackInt pidCallback = new ICallbackInt.Stub() {
+ @Override
+ public void call(final int pid) {
+ LauncherThread.post(new Runnable() {
+ @Override
+ public void run() {
+ onSetupConnectionResult(pid);
+ }
+ });
+ }
+ };
try {
- mPid = mService.setupConnection(bundle, mConnectionParams.mCallback);
- assert mPid != 0 : "Child service claims to be run by a process of pid=0.";
- } catch (android.os.RemoteException re) {
+ mService.setupConnection(bundle, pidCallback, mConnectionParams.mCallback);
+ } catch (RemoteException re) {
Log.e(TAG, "Failed to setup connection.", re);
}
// We proactively close the FDs rather than wait for GC & finalizer.
@@ -417,11 +440,6 @@ public class ChildProcessConnectionImpl implements ChildProcessConnection {
Log.w(TAG, "Failed to close FD.", ioe);
}
mConnectionParams = null;
-
- if (mConnectionCallback != null) {
- mConnectionCallback.onConnected(mPid);
- }
- mConnectionCallback = null;
} finally {
TraceEvent.end("ChildProcessConnectionImpl.doConnectionSetupLocked");
}

Powered by Google App Engine
This is Rietveld 408576698