[Chromecast] CWC: Check page state before notifying observers

During observer notification, the observer might mutate CWC, which can
cause the state DCHECKs to fail. We now check the state before notifying
observers. A DCHECK is also added to ensure CWC is not destroyed while
notifying observers.

Bug: internal b/124794528
Test: CQ, manual test on device with basic media flow: "OKG, play music"
Change-Id: Icb0c2f6e9d7dc4e3bad8598ba8ab196253dec900
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1497299
Reviewed-by: Luke Halliwell <halliwell@chromium.org>
Commit-Queue: Sean Topping <seantopping@chromium.org>
Cr-Commit-Position: refs/heads/master@{#637801}
2 files changed