Index: content/public/android/java/src/org/chromium/content/app/ChildProcessServiceImpl.java |
diff --git a/content/public/android/java/src/org/chromium/content/app/ChildProcessServiceImpl.java b/content/public/android/java/src/org/chromium/content/app/ChildProcessServiceImpl.java |
index fde50c8f4b2427b5b341b8026ae88bbb11505a8f..0c02ad8aa4c20fc8fd5ba0fa598b8977c9cadbba 100644 |
--- a/content/public/android/java/src/org/chromium/content/app/ChildProcessServiceImpl.java |
+++ b/content/public/android/java/src/org/chromium/content/app/ChildProcessServiceImpl.java |
@@ -67,6 +67,8 @@ public class ChildProcessServiceImpl { |
private ChromiumLinkerParams mLinkerParams; |
// Child library process type. |
private int mLibraryProcessType; |
+ // PID of the client of this service, set in bindToCaller(). |
+ private int mBoundCallingPid; |
private static AtomicReference<Context> sContext = new AtomicReference<>(null); |
private boolean mLibraryInitialized; |
@@ -97,7 +99,27 @@ public class ChildProcessServiceImpl { |
private final IChildProcessService.Stub mBinder = new IChildProcessService.Stub() { |
// NOTE: Implement any IChildProcessService methods here. |
@Override |
+ public boolean bindToCaller() { |
+ int callingPid = Binder.getCallingPid(); |
+ if (mBoundCallingPid == 0) { |
+ mBoundCallingPid = callingPid; |
+ } else if (mBoundCallingPid != callingPid) { |
+ Log.e(TAG, "This service is already bound by pid %d, cannot bind for pid %d", |
+ mBoundCallingPid, callingPid); |
+ return false; |
+ } |
+ return true; |
+ } |
+ |
+ @Override |
public int setupConnection(Bundle args, IChildProcessCallback callback) { |
+ int callingPid = Binder.getCallingPid(); |
+ if (mBoundCallingPid != callingPid) { |
+ Log.e(TAG, "Client pid %d does not match the bound pid %d", callingPid, |
Tobias Sargeant
2017/01/14 23:24:57
Maybe log a different message if mBoundCallingPid
Torne
2017/01/16 12:44:43
Yeah, this isn't threadsafe right now I think (the
Robert Sesek
2017/01/17 19:51:22
Done.
Robert Sesek
2017/01/17 19:51:22
Added a lock. Also mCallback was already not-threa
|
+ mBoundCallingPid); |
+ return -1; |
+ } |
+ |
mCallback = callback; |
getServiceInfo(args); |
return Process.myPid(); |