Worker: Introduce an observation mechanism for WorkerThread termination

This mechanism provides a way to observe WorkerThread termination from the main
thread. This is useful when an object living on the main thread needs to release
references to objects on the worker thread before it gets terminated.

As an example of using this mechanism, this CL applies it to WebSocket.
WorkerWebSocketChannel::Peer observes worker thread termination from the main
thread and asks DocumentWebSocketChannel to release references to objects on the
worker thread when the termination happens.

Design doc: https://docs.google.com/document/d/1rYFKem6SwghdISe_to5b4apORIKqjOpsV5FkE3f5WQ0/edit

BUG=575532

Review-Url: https://codereview.chromium.org/2025783002
Cr-Commit-Position: refs/heads/master@{#398886}
10 files changed