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

Side by Side Diff: content/browser/web_contents/aura/overscroll_navigation_overlay.cc

Issue 185793005: Replacing raw pointer to LayerAnimator with scoped_refptr in ScopedLayerAnimationSettings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding a unit test. Created 6 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | ui/compositor/layer_animator_unittest.cc » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/browser/web_contents/aura/overscroll_navigation_overlay.h" 5 #include "content/browser/web_contents/aura/overscroll_navigation_overlay.h"
6 6
7 #include "content/browser/frame_host/navigation_entry_impl.h" 7 #include "content/browser/frame_host/navigation_entry_impl.h"
8 #include "content/browser/renderer_host/render_view_host_impl.h" 8 #include "content/browser/renderer_host/render_view_host_impl.h"
9 #include "content/browser/web_contents/aura/image_window_delegate.h" 9 #include "content/browser/web_contents/aura/image_window_delegate.h"
10 #include "content/browser/web_contents/web_contents_impl.h" 10 #include "content/browser/web_contents/web_contents_impl.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 // Takes ownership of the layer. 70 // Takes ownership of the layer.
71 explicit OverlayDismissAnimator(scoped_ptr<ui::Layer> layer) 71 explicit OverlayDismissAnimator(scoped_ptr<ui::Layer> layer)
72 : layer_(layer.Pass()) { 72 : layer_(layer.Pass()) {
73 CHECK(layer_.get()); 73 CHECK(layer_.get());
74 } 74 }
75 75
76 // Starts the fadeout animation on the layer. When the animation finishes, 76 // Starts the fadeout animation on the layer. When the animation finishes,
77 // the object deletes itself along with the layer. 77 // the object deletes itself along with the layer.
78 void Animate() { 78 void Animate() {
79 DCHECK(layer_.get()); 79 DCHECK(layer_.get());
80 // Hold on to LayerAnimator to ensure it is not deleted before animation 80 ui::LayerAnimator* animator = layer_->GetAnimator();
81 // settings. Without this LayerAnimator would be deleted from SetOpacity if 81 // This makes SetOpacity() animate with default duration (which could be
82 // the animation duration is 0. 82 // zero, e.g. when running tests).
83 scoped_refptr<ui::LayerAnimator> animator(layer_->GetAnimator()); 83 ui::ScopedLayerAnimationSettings settings(animator);
84 { 84 animator->AddObserver(this);
85 // This makes SetOpacity() animate with default duration (which could be 85 layer_->SetOpacity(0);
86 // zero, e.g. when running tests).
87 ui::ScopedLayerAnimationSettings settings(animator);
88 animator->AddObserver(this);
89 layer_->SetOpacity(0);
90 }
91 } 86 }
92 87
93 // Overridden from ui::LayerAnimationObserver 88 // Overridden from ui::LayerAnimationObserver
94 virtual void OnLayerAnimationEnded( 89 virtual void OnLayerAnimationEnded(
95 ui::LayerAnimationSequence* sequence) OVERRIDE { 90 ui::LayerAnimationSequence* sequence) OVERRIDE {
96 delete this; 91 delete this;
97 } 92 }
98 93
99 virtual void OnLayerAnimationAborted( 94 virtual void OnLayerAnimationAborted(
100 ui::LayerAnimationSequence* sequence) OVERRIDE { 95 ui::LayerAnimationSequence* sequence) OVERRIDE {
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 bool OverscrollNavigationOverlay::OnMessageReceived( 293 bool OverscrollNavigationOverlay::OnMessageReceived(
299 const IPC::Message& message) { 294 const IPC::Message& message) {
300 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 295 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
301 IPC_BEGIN_MESSAGE_MAP(OverscrollNavigationOverlay, message) 296 IPC_BEGIN_MESSAGE_MAP(OverscrollNavigationOverlay, message)
302 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect) 297 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect)
303 IPC_END_MESSAGE_MAP() 298 IPC_END_MESSAGE_MAP()
304 return false; 299 return false;
305 } 300 }
306 301
307 } // namespace content 302 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | ui/compositor/layer_animator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698