Eliminate a potential race in IPC::ChannelProxy

Doing the following steps with ChannelProxy leads to a data race:
1) Create the ChannelProxy, but don't initialize it.
2) Add a filter.
3) Init the ChannelProxy.

The problem is, AddFilter() posts a task from the Listener thread to the IPC task runner to do OnAddFilter. Prior to this patch, OnAddFilter will try to read channel_ even though channel_ may not have been initialized, and it's accessed without any synchronization.

This patch only really adds the filter if peer_pid_ has been set on the IPC::Channel thread; otherwise, it waits until the connection has been established to really add filters.

See the bug for more detail.

BUG=244383

Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=256188

Review URL: https://codereview.chromium.org/183553004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@258406 0039d316-1c4b-4281-b951-d872f2087c98


CrOS-Libchrome-Original-Commit: 7e3d75264e9fc8577743a0b3c26ffe4d5e95697c
2 files changed
tree: f883c30eb5c10c737c95736766c99d6ef4d62815
  1. base/
  2. build/
  3. components/
  4. dbus/
  5. ipc/
  6. mojo/
  7. testing/
  8. third_party/
  9. ui/