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

Side by Side Diff: ash/system/tray/system_tray_bubble.cc

Issue 11647022: Fix layer leak in SystemTrayBubble (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: alternative Created 8 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/valgrind/memcheck/suppressions.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/system/tray/system_tray_bubble.h" 5 #include "ash/system/tray/system_tray_bubble.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/system/tray/system_tray.h" 8 #include "ash/system/tray/system_tray.h"
9 #include "ash/system/tray/system_tray_delegate.h" 9 #include "ash/system/tray/system_tray_delegate.h"
10 #include "ash/system/tray/system_tray_item.h" 10 #include "ash/system/tray/system_tray_item.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 147
148 void SystemTrayBubble::UpdateView( 148 void SystemTrayBubble::UpdateView(
149 const std::vector<ash::SystemTrayItem*>& items, 149 const std::vector<ash::SystemTrayItem*>& items,
150 BubbleType bubble_type) { 150 BubbleType bubble_type) {
151 DCHECK(bubble_type != BUBBLE_TYPE_NOTIFICATION); 151 DCHECK(bubble_type != BUBBLE_TYPE_NOTIFICATION);
152 DCHECK(bubble_type != bubble_type_); 152 DCHECK(bubble_type != bubble_type_);
153 153
154 const int kSwipeDelayMS = 150; 154 const int kSwipeDelayMS = 150;
155 base::TimeDelta swipe_duration = 155 base::TimeDelta swipe_duration =
156 base::TimeDelta::FromMilliseconds(kSwipeDelayMS); 156 base::TimeDelta::FromMilliseconds(kSwipeDelayMS);
157 ui::Layer* layer = bubble_view_->RecreateLayer(); 157 scoped_ptr<ui::Layer> scoped_layer(bubble_view_->RecreateLayer());
158 // Keep the reference to layer as we need it after releasing it.
159 ui::Layer* layer = scoped_layer.get();
158 DCHECK(layer); 160 DCHECK(layer);
159 layer->SuppressPaint(); 161 layer->SuppressPaint();
160 162
161 // When transitioning from detailed view to default view, animate the existing 163 // When transitioning from detailed view to default view, animate the existing
162 // view (slide out towards the right). 164 // view (slide out towards the right).
163 if (bubble_type == BUBBLE_TYPE_DEFAULT) { 165 if (bubble_type == BUBBLE_TYPE_DEFAULT) {
164 // Make sure the old view is visibile over the new view during the 166 // Make sure the old view is visibile over the new view during the
165 // animation. 167 // animation.
166 layer->parent()->StackAbove(layer, bubble_view_->layer()); 168 layer->parent()->StackAbove(layer, bubble_view_->layer());
167 ui::ScopedLayerAnimationSettings settings(layer->GetAnimator()); 169 ui::ScopedLayerAnimationSettings settings(layer->GetAnimator());
168 settings.AddObserver(new AnimationObserverDeleteLayer(layer)); 170 settings.AddObserver(
171 new AnimationObserverDeleteLayer(scoped_layer.release()));
169 settings.SetTransitionDuration(swipe_duration); 172 settings.SetTransitionDuration(swipe_duration);
170 settings.SetTweenType(ui::Tween::EASE_OUT); 173 settings.SetTweenType(ui::Tween::EASE_OUT);
171 gfx::Transform transform; 174 gfx::Transform transform;
172 transform.Translate(layer->bounds().width(), 0.0); 175 transform.Translate(layer->bounds().width(), 0.0);
173 layer->SetTransform(transform); 176 layer->SetTransform(transform);
174 } 177 }
175 178
176 { 179 {
177 // Add a shadow layer to make the old layer darker as the animation 180 // Add a shadow layer to make the old layer darker as the animation
178 // progresses. 181 // progresses.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 // When transitioning from default view to detailed view, animate the new 223 // When transitioning from default view to detailed view, animate the new
221 // view (slide in from the right). 224 // view (slide in from the right).
222 if (bubble_type == BUBBLE_TYPE_DETAILED) { 225 if (bubble_type == BUBBLE_TYPE_DETAILED) {
223 ui::Layer* new_layer = bubble_view_->layer(); 226 ui::Layer* new_layer = bubble_view_->layer();
224 gfx::Rect bounds = new_layer->bounds(); 227 gfx::Rect bounds = new_layer->bounds();
225 gfx::Transform transform; 228 gfx::Transform transform;
226 transform.Translate(bounds.width(), 0.0); 229 transform.Translate(bounds.width(), 0.0);
227 new_layer->SetTransform(transform); 230 new_layer->SetTransform(transform);
228 { 231 {
229 ui::ScopedLayerAnimationSettings settings(new_layer->GetAnimator()); 232 ui::ScopedLayerAnimationSettings settings(new_layer->GetAnimator());
230 settings.AddObserver(new AnimationObserverDeleteLayer(layer)); 233 settings.AddObserver(
234 new AnimationObserverDeleteLayer(scoped_layer.release()));
231 settings.SetTransitionDuration(swipe_duration); 235 settings.SetTransitionDuration(swipe_duration);
232 settings.SetTweenType(ui::Tween::EASE_OUT); 236 settings.SetTweenType(ui::Tween::EASE_OUT);
233 new_layer->SetTransform(gfx::Transform()); 237 new_layer->SetTransform(gfx::Transform());
234 } 238 }
235 } 239 }
236 } 240 }
237 241
238 void SystemTrayBubble::InitView(views::View* anchor, 242 void SystemTrayBubble::InitView(views::View* anchor,
239 user::LoginStatus login_status, 243 user::LoginStatus login_status,
240 TrayBubbleView::InitParams* init_params) { 244 TrayBubbleView::InitParams* init_params) {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 bool is_default_bubble = bubble_type_ == BUBBLE_TYPE_DEFAULT; 345 bool is_default_bubble = bubble_type_ == BUBBLE_TYPE_DEFAULT;
342 bubble_view_->AddChildView(new TrayPopupItemContainer( 346 bubble_view_->AddChildView(new TrayPopupItemContainer(
343 view, is_default_bubble, 347 view, is_default_bubble,
344 is_default_bubble && (i < items_.size() - 2))); 348 is_default_bubble && (i < items_.size() - 2)));
345 } 349 }
346 } 350 }
347 } 351 }
348 352
349 } // namespace internal 353 } // namespace internal
350 } // namespace ash 354 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | tools/valgrind/memcheck/suppressions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698