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

Unified Diff: ui/wm/core/window_animations.cc

Issue 343753007: Fix a leak in wm::AnimateOnChildWindowVisibilityChanged(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove expect. Created 6 years, 5 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 | « no previous file | ui/wm/core/window_animations_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/wm/core/window_animations.cc
diff --git a/ui/wm/core/window_animations.cc b/ui/wm/core/window_animations.cc
index a79db3a15d6c45a76d6cdb78a8e3e7dc2db5035a..22fd43d387406c69d776c7c2344b5a7a895541ef 100644
--- a/ui/wm/core/window_animations.cc
+++ b/ui/wm/core/window_animations.cc
@@ -58,7 +58,8 @@ const float kWindowAnimation_Vertical_TranslateY = 15.f;
// The subclass will determine when the animation is completed.
class HidingWindowAnimationObserverBase : public aura::WindowObserver {
public:
- HidingWindowAnimationObserverBase(aura::Window* window) : window_(window) {
+ explicit HidingWindowAnimationObserverBase(aura::Window* window)
+ : window_(window) {
window_->AddObserver(this);
}
virtual ~HidingWindowAnimationObserverBase() {
@@ -396,31 +397,29 @@ class RotateHidingWindowAnimationObserver
: public HidingWindowAnimationObserverBase,
public ui::LayerAnimationObserver {
public:
- RotateHidingWindowAnimationObserver(aura::Window* window)
- : HidingWindowAnimationObserverBase(window), last_sequence_(NULL) {}
+ explicit RotateHidingWindowAnimationObserver(aura::Window* window)
+ : HidingWindowAnimationObserverBase(window) {}
virtual ~RotateHidingWindowAnimationObserver() {}
- void set_last_sequence(ui::LayerAnimationSequence* last_sequence) {
- last_sequence_ = last_sequence;
+ // Destroys itself after |last_sequence| ends or is aborted. Does not take
+ // ownership of |last_sequence|, which should not be NULL.
+ void SetLastSequence(ui::LayerAnimationSequence* last_sequence) {
+ last_sequence->AddObserver(this);
}
// ui::LayerAnimationObserver:
virtual void OnLayerAnimationEnded(
ui::LayerAnimationSequence* sequence) OVERRIDE {
- if (last_sequence_ == sequence)
- OnAnimationCompleted();
+ OnAnimationCompleted();
}
virtual void OnLayerAnimationAborted(
ui::LayerAnimationSequence* sequence) OVERRIDE {
- if (last_sequence_ == sequence)
- OnAnimationCompleted();
+ OnAnimationCompleted();
}
virtual void OnLayerAnimationScheduled(
ui::LayerAnimationSequence* sequence) OVERRIDE {}
private:
- ui::LayerAnimationSequence* last_sequence_;
-
DISALLOW_COPY_AND_ASSIGN(RotateHidingWindowAnimationObserver);
};
@@ -482,8 +481,9 @@ void AddLayerAnimationsForRotate(aura::Window* window, bool show) {
ui::LayerAnimationSequence* last_sequence =
new ui::LayerAnimationSequence(transition.release());
window->layer()->GetAnimator()->ScheduleAnimation(last_sequence);
+
if (observer) {
- observer->set_last_sequence(last_sequence);
+ observer->SetLastSequence(last_sequence);
observer->DetachAndRecreateLayers();
}
}
« no previous file with comments | « no previous file | ui/wm/core/window_animations_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698