Revert 153291 - Fixes crash introduced @ 153047 (you can hit crash by maximizing a
window). The cross fade code deletes the layer when the animation
finishes. The newly added code was accessing members after the
animation finished and the animator was deleted, resulting in the
crash. Since I'm sure this will come up more in the future I've
restructured the code to allow for deletion when calling out like
this.

The cross fade test exercises this code path now, but I'll see about a
more focused tests shortly.

BUG=129033
TEST=covered by tests.
[email protected]

Review URL: https://chromiumcodereview.appspot.com/10874064

[email protected]
Review URL: https://chromiumcodereview.appspot.com/10882043

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@153312 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/ui/compositor/layer_animator.cc b/ui/compositor/layer_animator.cc
index 1921474..5fc289b 100644
--- a/ui/compositor/layer_animator.cc
+++ b/ui/compositor/layer_animator.cc
@@ -43,16 +43,13 @@
       transition_duration_(transition_duration),
       tween_type_(Tween::LINEAR),
       is_started_(false),
-      disable_timer_for_test_(false),
-      destroyed_(NULL) {
+      disable_timer_for_test_(false) {
 }
 
 LayerAnimator::~LayerAnimator() {
   for (size_t i = 0; i < running_animations_.size(); ++i)
     running_animations_[i].sequence->OnAnimatorDestroyed();
   ClearAnimations();
-  if (destroyed_)
-    *destroyed_ = true;
 }
 
 // static
@@ -283,8 +280,6 @@
 void LayerAnimator::Step(base::TimeTicks now) {
   TRACE_EVENT0("ui", "LayerAnimator::Step");
 
-  bool destroyed = false;
-  destroyed_ = &destroyed;
   last_step_time_ = now;
   // We need to make a copy of the running animations because progressing them
   // and finishing them may indirectly affect the collection of running
@@ -299,15 +294,11 @@
     if (delta >= running_animations_copy[i].sequence->duration() &&
         !running_animations_copy[i].sequence->is_cyclic()) {
       FinishAnimation(running_animations_copy[i].sequence);
-      if (destroyed)
-        return;
       needs_redraw = true;
-    } else if (ProgressAnimation(running_animations_copy[i].sequence, delta)) {
+    } else if (ProgressAnimation(running_animations_copy[i].sequence, delta))
       needs_redraw = true;
-    }
   }
 
-  destroyed_ = NULL;
   if (needs_redraw && delegate())
     delegate()->ScheduleDrawForAnimation();
 }