Blink: Introduce LifecycleNotifier::ForEachObserver().
LifecycleNotifier currently exposes its internal state (observers_, iteration_state_) to subclasses, and relies on the subclasses to correctly update iteration_state_ while iterating over observers_, like PageVisibilityNotifier::NotifyPageVisibilityChanged() does. Sadly, it's easy to get this wrong, as shown by SynchronousMutationNotifier (does not update iteration_state_ at all) and ContextLifecycleNotifier (only updates iteration_state_ in some cases). This CL makes the LifecycleNotifier state private, and adds a ForEachObserver() method that safely iterates over observers_, encapsulating the needed changes to iteration_state_ and a cast from LifecycleObserverBase* to the desired observer type. Change-Id: Ibb23f2c7e2bba9bdf08d49e8569a354934ed4e11 Reviewed-on: https://chromium-review.googlesource.com/1132674Reviewed-by:Kent Tamura <tkent@chromium.org> Commit-Queue: Victor Costan <pwnall@chromium.org> Cr-Commit-Position: refs/heads/master@{#574076}
Showing
Please register or sign in to comment