Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(692)

Unified Diff: ui/compositor/layer_animation_observer.h

Issue 1369393002: Added a CallbackLayerAnimationObserver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed concerns from patch set 8. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/compositor/compositor.gyp ('k') | ui/compositor/test/layer_animation_observer_test_api.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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:
« no previous file with comments | « ui/compositor/compositor.gyp ('k') | ui/compositor/test/layer_animation_observer_test_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698