Index: components/arc/arc_bridge_bootstrap.cc |
diff --git a/components/arc/arc_bridge_bootstrap.cc b/components/arc/arc_bridge_bootstrap.cc |
index 1d7a94f55178b590325f95b1ce23fff6f1c2afb5..a176af5999e9b5a09f463e367a1511c9f3c261f8 100644 |
--- a/components/arc/arc_bridge_bootstrap.cc |
+++ b/components/arc/arc_bridge_bootstrap.cc |
@@ -32,17 +32,15 @@ |
namespace arc { |
-namespace { |
+// This assumes all video accelerator clients are from the same namespace and |
+// the max pid of the said namespace is kPidMask. |
+base::ProcessHandle RemapChildPid(uint32_t pid) { |
Luis Héctor Chávez
2016/03/28 16:01:27
nit: s/uint32_t/base::ProcessHandle/ in all this.
kcwu
2016/03/28 18:16:49
Done.
|
+ uint32_t kPidBase = 0x3DE0EA7C; // arbitrarily chosen. |
+ uint32_t kPidMask = 0x7fff; // the default, 32k. |
+ return kPidBase + (pid & kPidMask); |
+} |
-// We do not know the PID of ARC, since Chrome does not create it directly. |
-// Since Mojo in POSIX does not use the child PID except as an unique |
-// identifier for the routing table, rather than doing a lot of plumbing in the |
-// whole system to get the correct PID, just use an arbitrary number that will |
-// never be used by a legitimate process. Chrome OS assigns unassigned PIDs |
-// sequentially until it reaches a certain maximum value (Chrome OS uses the |
-// default value of 32k), at which point it loops around to zero. An arbitrary |
-// number larger than the maximum should be safe. |
-const pid_t kArcPid = 0x3DE0EA7C; |
+namespace { |
const base::FilePath::CharType kArcBridgeSocketPath[] = |
FILE_PATH_LITERAL("/var/run/chrome/arc_bridge.sock"); |
@@ -260,6 +258,11 @@ base::ScopedFD ArcBridgeBootstrapImpl::AcceptInstanceConnection( |
} |
base::ScopedFD scoped_fd(raw_fd); |
+ // We do not know the PID of ARC, since Chrome does not create it directly |
+ // and it may in the difference namespace. Here we assume the pid is zero |
+ // (should not happen in its namespace) and RemapChildPid to safe range (not |
+ // conflict in our namespace). |
+ const pid_t kArcPid = RemapChildPid(0); |
Luis Héctor Chávez
2016/03/28 16:01:27
nit: const base::ProcessHandle
kcwu
2016/03/28 18:16:49
Done.
|
mojo::edk::ScopedPlatformHandle child_handle = |
mojo::edk::ChildProcessLaunched(kArcPid); |