Explicit notification and removal of lifecycle observers.

To help make disposing of execution contexts cleaner in a setting
where both a context and its lifetime observers are being finalized
by a garbage collector, add support for explicitly clearing out
all lifecycle observers:

protected:
  void LifecycleNotifier<T>::removeAndNotifyAllObservers()

Notifying them that the context has been destroyed while doing so.
An operation that was previously (only) done by the LifecycleNotifier
destructor.

Also provide a convenience method over ExecutionContext for clearing
out its observers:

  void ExecutionContext::removeAllLifecycleObservers()

The operation is used here when shutting down and finalizing a worker
thread and its global scope -- explicitly severing the connection
of all observers to its execution context before performing the
final garbage collection.

Doing so ensures that all observer objects being finalized during that
garbage collection will not have access to its execution context object.
A heap object that may or may not have been finalized by the garbage
collector already.

R=haraken@chromium.org,ager@chromium.org,abarth@chromium.org
BUG=340522

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

git-svn-id: svn://svn.chromium.org/blink/trunk@169435 bbb929c8-8fbe-4397-9dbb-9b2b20218538
8 files changed
tree: 6d67bd954ff7afb9d5d8433e583a0d1dc01dccec
  1. third_party/