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

Side by Side Diff: sky/shell/ui/animator.cc

Issue 952273003: Make WebView::close not crash and start to fix navigation in SkyShell (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Fixed Created 5 years, 10 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 | « sky/shell/ui/animator.h ('k') | sky/shell/ui/engine.h » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "sky/shell/ui/animator.h" 5 #include "sky/shell/ui/animator.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 9
10 namespace sky { 10 namespace sky {
(...skipping 16 matching lines...) Expand all
27 engine_requested_frame_ = true; 27 engine_requested_frame_ = true;
28 28
29 if (!frame_in_progress_) { 29 if (!frame_in_progress_) {
30 frame_in_progress_ = true; 30 frame_in_progress_ = true;
31 base::MessageLoop::current()->PostTask( 31 base::MessageLoop::current()->PostTask(
32 FROM_HERE, 32 FROM_HERE,
33 base::Bind(&Animator::BeginFrame, weak_factory_.GetWeakPtr())); 33 base::Bind(&Animator::BeginFrame, weak_factory_.GetWeakPtr()));
34 } 34 }
35 } 35 }
36 36
37 void Animator::CancelFrameRequest() {
38 engine_requested_frame_ = false;
39 }
40
37 void Animator::BeginFrame() { 41 void Animator::BeginFrame() {
38 DCHECK(frame_in_progress_); 42 DCHECK(frame_in_progress_);
39 DCHECK(engine_requested_frame_); 43 // There could be a request in the message loop at time of cancel.
44 if (!engine_requested_frame_) {
45 frame_in_progress_ = false;
46 return;
47 }
40 engine_requested_frame_ = false; 48 engine_requested_frame_ = false;
41 49
42 engine_->BeginFrame(base::TimeTicks::Now()); 50 engine_->BeginFrame(base::TimeTicks::Now());
43 config_.gpu_task_runner->PostTaskAndReply( 51 config_.gpu_task_runner->PostTaskAndReply(
44 FROM_HERE, 52 FROM_HERE,
45 base::Bind(&GPUDelegate::Draw, config_.gpu_delegate, engine_->Paint()), 53 base::Bind(&GPUDelegate::Draw, config_.gpu_delegate, engine_->Paint()),
46 base::Bind(&Animator::OnFrameComplete, weak_factory_.GetWeakPtr())); 54 base::Bind(&Animator::OnFrameComplete, weak_factory_.GetWeakPtr()));
47 } 55 }
48 56
49 void Animator::OnFrameComplete() { 57 void Animator::OnFrameComplete() {
50 DCHECK(frame_in_progress_); 58 DCHECK(frame_in_progress_);
51 frame_in_progress_ = false; 59 frame_in_progress_ = false;
52 if (engine_requested_frame_) { 60 if (engine_requested_frame_) {
53 frame_in_progress_ = true; 61 frame_in_progress_ = true;
54 BeginFrame(); 62 BeginFrame();
55 } 63 }
56 } 64 }
57 65
58 } // namespace shell 66 } // namespace shell
59 } // namespace sky 67 } // namespace sky
OLDNEW
« no previous file with comments | « sky/shell/ui/animator.h ('k') | sky/shell/ui/engine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698