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..986631672654dd8a83b515ba4a835e9dda6c4cb6 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; |
@@ -46,9 +50,18 @@ class COMPOSITOR_EXPORT LayerAnimationObserver { |
// If the animator 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 you override this function to return true AND you are |
+ // using the pattern described below, then make sure you explicity remove |
danakj
2015/10/12 21:33:56
I would say "... and you are the owner of the obse
bruthig
2015/10/13 19:41:42
I've tried to re-word this. PTAL.
|
+ // yourself as an observer before the animator is destroyed! |
+ // |
+ // This opt-in pattern is used because it is a common pattern for a class to |
+ // be the observer of an animation that it itself owns. In such a case the |
+ // animator will be destroyed as the owning class is destructed and we don't |
+ // want the NotifyAbort being invoked on a partially destroyed observer. |
virtual bool RequiresNotificationWhenAnimatorDestroyed() const; |
// Called when |this| is added to |sequence|'s observer list. |
@@ -66,6 +79,7 @@ class COMPOSITOR_EXPORT LayerAnimationObserver { |
private: |
friend class LayerAnimationSequence; |
+ friend class test::LayerAnimationObserverTestApi; |
danakj
2015/10/12 21:33:56
What's the advantage to this instead of just makin
bruthig
2015/10/13 19:41:42
There are a few advantages to testing the Callback
|
// Called when |this| is added to |sequence|'s observer list. |
void AttachedToSequence(LayerAnimationSequence* sequence); |