Index: ui/compositor/layer_animation_observer.cc |
diff --git a/ui/compositor/layer_animation_observer.cc b/ui/compositor/layer_animation_observer.cc |
index 2d7402b5f1aee921dab7e68d8a1623b252299470..bb0771a476298f678d1cdb11d0d2e4a362fe4b3d 100644 |
--- a/ui/compositor/layer_animation_observer.cc |
+++ b/ui/compositor/layer_animation_observer.cc |
@@ -120,4 +120,113 @@ void ImplicitAnimationObserver::CheckCompleted() { |
} |
} |
+//////////////////////////////////////////////////////////////////////////////// |
+// AnimationFinishedObserver |
+ |
+AnimationFinishedObserver::AnimationFinishedObserver( |
+ base::Callback<void(void)> &callback) |
+ : callback_(callback), |
+ sequences_attached_(0), |
+ sequences_completed_(0), |
+ paused_(false) { |
+} |
+ |
+AnimationFinishedObserver::~AnimationFinishedObserver() { |
+} |
+ |
+void AnimationFinishedObserver::Pause() { |
+ paused_ = true; |
+} |
+ |
+void AnimationFinishedObserver::Unpause() { |
+ if (!paused_) |
+ return; |
+ paused_ = false; |
+ if (sequences_completed_ == sequences_attached_) { |
+ callback_.Run(); |
+ delete this; |
+ } |
+} |
+ |
+void AnimationFinishedObserver::OnLayerAnimationEnded( |
+ ui::LayerAnimationSequence* seq) { |
+ sequences_completed_++; |
+ if ((sequences_completed_ == sequences_attached_) && !paused_) { |
+ callback_.Run(); |
+ delete this; |
+ } |
+} |
+ |
+void AnimationFinishedObserver::OnLayerAnimationAborted( |
+ ui::LayerAnimationSequence* seq) { |
+ sequences_completed_++; |
+ if ((sequences_completed_ == sequences_attached_) && !paused_) |
+ delete this; |
+} |
+ |
+void AnimationFinishedObserver::OnAttachedToSequence( |
+ LayerAnimationSequence* sequence) { |
+ LayerAnimationObserver::OnAttachedToSequence(sequence); |
+ sequences_attached_++; |
+} |
+ |
+//////////////////////////////////////////////////////////////////////////////// |
+// AnimationAbortedObserver |
+ |
+AnimationAbortedObserver::AnimationAbortedObserver( |
+ base::Callback<void(void)> &callback) |
+ : callback_(callback), |
+ sequences_attached_(0), |
+ sequences_completed_(0), |
+ aborted_(false) { |
+} |
+ |
+AnimationAbortedObserver::~AnimationAbortedObserver() { |
+ if (sequences_completed_ != sequences_attached_) { |
+ if (aborted_) |
+ callback_.Run(); |
+ } |
+} |
+ |
+void AnimationAbortedObserver::Pause() { |
+ paused_ = true; |
+} |
+ |
+void AnimationAbortedObserver::Unpause() { |
+ if (!paused_) |
+ return; |
+ paused_ = false; |
+ if (sequences_completed_ == sequences_attached_) { |
+ if (aborted_) |
+ callback_.Run(); |
+ delete this; |
+ } |
+} |
+ |
+void AnimationAbortedObserver::OnLayerAnimationEnded( |
+ ui::LayerAnimationSequence* seq) { |
+ sequences_completed_++; |
+ if ((sequences_completed_ == sequences_attached_) && !paused_) { |
+ if (aborted_) |
+ callback_.Run(); |
+ delete this; |
+ } |
+} |
+ |
+void AnimationAbortedObserver::OnLayerAnimationAborted( |
+ ui::LayerAnimationSequence* seq) { |
+ aborted_ = true; |
+ sequences_completed_++; |
+ if ((sequences_completed_ == sequences_attached_) && !paused_) { |
+ callback_.Run(); |
+ delete this; |
+ } |
+} |
+ |
+void AnimationAbortedObserver::OnAttachedToSequence( |
+ LayerAnimationSequence* sequence) { |
+ LayerAnimationObserver::OnAttachedToSequence(sequence); |
+ sequences_attached_++; |
+} |
+ |
} // namespace ui |