Fix some interleaving issues in EmbeddedWorkerInstance.
The embedded worker startup sequence involves thread hopping and async
callbacks, so there's some cases that could cause bugs:
One is detach during startup:
(1) ProcessAllocated sets process_id_
(2) Hop to UI thread for RegisterDevToolsManagerOnUI
(3) The render process dies, detaching and clearing process_id_
(4) UI thread work completes, hops back to SendStartWorker
(5) SendStartWorker tries to send an IPC to process_id -1, hits DCHECK.
Another is calling Stop() during startup:
(1) Call Start()
(2) Hop to UI thread for AllocateProcess
(3) Call Stop()
(4) Stop tries to send an IPC to process_id -1, gets error.
(5) Stop sets status to STOPPING, and will remain in stopping forever.
The fix is to add checks to detect these conditions.
BUG=515759,509904
Review URL: https://codereview.chromium.org/
1289443002
Cr-Commit-Position: refs/heads/master@{#342998}