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

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

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


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