| Index: ui/compositor/layer_animation_observer.h
|
| diff --git a/ui/compositor/layer_animation_observer.h b/ui/compositor/layer_animation_observer.h
|
| index 5a130708552fbd2610b4a3c3ff748ac9a0864195..63f146a7580c90617848dfb9e257098003a82264 100644
|
| --- a/ui/compositor/layer_animation_observer.h
|
| +++ b/ui/compositor/layer_animation_observer.h
|
| @@ -8,6 +8,7 @@
|
| #include <set>
|
|
|
| #include "base/basictypes.h"
|
| +#include "base/callback.h"
|
| #include "base/compiler_specific.h"
|
| #include "ui/compositor/compositor_export.h"
|
|
|
| @@ -125,6 +126,108 @@ class COMPOSITOR_EXPORT ImplicitAnimationObserver
|
| bool first_sequence_scheduled_;
|
| };
|
|
|
| +// This observer is intended to use in cases when some action have to be taken
|
| +// once some animation successfully completes (i.e. it was not aborted).
|
| +// Observer will count a number of sequences it is attached to, and a number of
|
| +// finished sequences (either Ended or Aborted). Once these two numbers are
|
| +// equal, observer will delete itself, calling callback passed to constructor if
|
| +// there was no aborted animations.
|
| +// This way it can be either used to wait for some animation to be finished in
|
| +// multiple layers, to wait once a sequence of animations is finished in one
|
| +// layer or the mixture of both.
|
| +class COMPOSITOR_EXPORT AnimationFinishedObserver
|
| + : public LayerAnimationObserver {
|
| + public:
|
| + explicit AnimationFinishedObserver(base::Closure &callback);
|
| + virtual ~AnimationFinishedObserver();
|
| +
|
| + // Pauses observer: no checks will be made while paused. It can be used when
|
| + // sequence have some immediate animations in the beginning.
|
| + void Pause();
|
| +
|
| + // Unpauses observer. It does a check ant calls callback if conditions are
|
| + // met.
|
| + void Unpause();
|
| +
|
| + private:
|
| + // LayerAnimationObserver implementation
|
| + virtual void OnLayerAnimationEnded(
|
| + LayerAnimationSequence* sequence) OVERRIDE;
|
| + virtual void OnLayerAnimationAborted(
|
| + LayerAnimationSequence* sequence) OVERRIDE;
|
| + virtual void OnLayerAnimationScheduled(
|
| + LayerAnimationSequence* sequence) OVERRIDE {};
|
| + virtual void OnAttachedToSequence(
|
| + LayerAnimationSequence* sequence) OVERRIDE;
|
| +
|
| + // Callback to be called.
|
| + base::Closure callback_;
|
| +
|
| + // Number of sequences this observer was attached to.
|
| + int sequences_attached_;
|
| +
|
| + // Number of sequences either ended or aborted.
|
| + int sequences_completed_;
|
| +
|
| + bool paused_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(AnimationFinishedObserver);
|
| +};
|
| +
|
| +// This observer is intended to use in cases when some action have to be taken
|
| +// once some animation was aborted. Observer will count a number of sequences it
|
| +// is attached to, and a number of finished sequences (either Ended or Aborted).
|
| +// Once these two numbers are equal, observer will delete itself, calling
|
| +// callback passed to constructor if there was at least one aborted animation.
|
| +// This way it can be either used to wait for some animation to be cancelled in
|
| +// multiple layers, to wait once a sequence of animations is cancelled in one
|
| +// layer or the mixture of both.
|
| +// If this observer is deleted before all animations complete, it will call
|
| +// |callback|, so it is safe to use it in conjunction with
|
| +// AnimationFinishedObserver to clean up resources.
|
| +
|
| +class COMPOSITOR_EXPORT AnimationAbortedObserver
|
| + : public LayerAnimationObserver {
|
| + public:
|
| + explicit AnimationAbortedObserver(base::Closure &callback);
|
| + virtual ~AnimationAbortedObserver();
|
| +
|
| + // Pauses observer: no checks will be made while paused. It can be used when
|
| + // sequence have some immediate animations in the beginning.
|
| + void Pause();
|
| +
|
| + // Unpauses observer. It does a check ant calls callback if conditions are
|
| + // met.
|
| + void Unpause();
|
| +
|
| + private:
|
| + // LayerAnimationObserver implementation
|
| + virtual void OnLayerAnimationEnded(
|
| + LayerAnimationSequence* sequence) OVERRIDE;
|
| + virtual void OnLayerAnimationAborted(
|
| + LayerAnimationSequence* sequence) OVERRIDE;
|
| + virtual void OnLayerAnimationScheduled(
|
| + LayerAnimationSequence* sequence) OVERRIDE {};
|
| + virtual void OnAttachedToSequence(
|
| + LayerAnimationSequence* sequence) OVERRIDE;
|
| +
|
| + // Callback to be called.
|
| + base::Closure callback_;
|
| +
|
| + // Number of sequences this observer was attached to.
|
| + int sequences_attached_;
|
| +
|
| + // Number of sequences either ended or aborted.
|
| + int sequences_completed_;
|
| +
|
| + // True if at lease one sequence was aborted.
|
| + bool aborted_;
|
| +
|
| + bool paused_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(AnimationAbortedObserver);
|
| +};
|
| +
|
| } // namespace ui
|
|
|
| #endif // UI_COMPOSITOR_LAYER_ANIMATION_OBSERVER_H_
|
|
|