Index: ui/compositor/layer_animation_observer.h |
diff --git a/ui/compositor/layer_animation_observer.h b/ui/compositor/layer_animation_observer.h |
index 26bfdfaf0affe45c1578e535741cafe3e9f945e2..01486ccd90903fd1fda63e936eedc0ee28defa2d 100644 |
--- a/ui/compositor/layer_animation_observer.h |
+++ b/ui/compositor/layer_animation_observer.h |
@@ -15,6 +15,10 @@ |
namespace ui { |
+namespace test { |
+class LayerAnimationObserverTestApi; |
+} // namespace test |
+ |
class LayerAnimationSequence; |
class ScopedLayerAnimationSettings; |
class ImplicitAnimationObserver; |
@@ -44,11 +48,23 @@ class COMPOSITOR_EXPORT LayerAnimationObserver { |
LayerAnimationObserver(); |
virtual ~LayerAnimationObserver(); |
- // If the animator is destroyed during an animation, the animations are |
+ // If the LayerAnimator is destroyed during an animation, the animations are |
// aborted. The resulting NotifyAborted notifications will NOT be sent to |
- // this observer if this function returns false. NOTE: IF YOU override THIS |
- // FUNCTION TO RETURN TRUE, YOU MUST REMEMBER TO REMOVE YOURSELF AS AN |
- // OBSERVER WHEN YOU ARE DESTROYED. |
+ // this observer if this function returns false. An observer who wants to |
+ // receive the NotifyAborted notifications during destruction can override |
+ // this function to return true. |
+ // |
+ // *** IMPORTANT ***: If a class overrides this function to return true and |
+ // that class is a direct or indirect owner of the LayerAnimationSequence |
+ // being observed, then the class must explicitly remove itself as an |
+ // observer during destruction of the LayerAnimationObserver! This is to |
+ // ensure that a partially destroyed observer isn't notified with an |
+ // OnLayerAnimationAborted() call when the LayerAnimator is destroyed. |
+ // |
+ // This opt-in pattern is used because it is common for a class to be the |
+ // observer of a LayerAnimationSequence that it owns indirectly because it |
+ // owns the Layer which owns the LayerAnimator which owns the |
+ // LayerAnimationSequence. |
virtual bool RequiresNotificationWhenAnimatorDestroyed() const; |
// Called when |this| is added to |sequence|'s observer list. |
@@ -66,6 +82,7 @@ class COMPOSITOR_EXPORT LayerAnimationObserver { |
private: |
friend class LayerAnimationSequence; |
+ friend class test::LayerAnimationObserverTestApi; |
// Called when |this| is added to |sequence|'s observer list. |
void AttachedToSequence(LayerAnimationSequence* sequence); |
@@ -81,6 +98,8 @@ class COMPOSITOR_EXPORT LayerAnimationObserver { |
// An implicit animation observer is intended to be used in conjunction with a |
// ScopedLayerAnimationSettings object in order to receive a notification when |
// all implicit animations complete. |
+// TODO(bruthig): Unify the ImplicitAnimationObserver with the |
+// CallbackLayerAnimationObserver. (See www.crbug.com/542825). |
class COMPOSITOR_EXPORT ImplicitAnimationObserver |
: public LayerAnimationObserver { |
public: |