| OLD | NEW | 
|---|
| 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 "ui/compositor/test/draw_waiter_for_test.h" | 5 #include "ui/compositor/test/draw_waiter_for_test.h" | 
| 6 | 6 | 
| 7 #include "ui/compositor/compositor.h" | 7 #include "ui/compositor/compositor.h" | 
| 8 | 8 | 
| 9 namespace ui { | 9 namespace ui { | 
| 10 | 10 | 
| 11 // static | 11 // static | 
| 12 void DrawWaiterForTest::Wait(Compositor* compositor) { | 12 void DrawWaiterForTest::WaitForCompositingStarted(Compositor* compositor) { | 
| 13   DrawWaiterForTest waiter; | 13   DrawWaiterForTest waiter(WAIT_FOR_COMPOSITING_STARTED); | 
| 14   waiter.wait_for_commit_ = false; | 14   waiter.WaitImpl(compositor); | 
|  | 15 } | 
|  | 16 | 
|  | 17 void DrawWaiterForTest::WaitForCompositingEnded(Compositor* compositor) { | 
|  | 18   DrawWaiterForTest waiter(WAIT_FOR_COMPOSITING_ENDED); | 
| 15   waiter.WaitImpl(compositor); | 19   waiter.WaitImpl(compositor); | 
| 16 } | 20 } | 
| 17 | 21 | 
| 18 // static | 22 // static | 
| 19 void DrawWaiterForTest::WaitForCommit(Compositor* compositor) { | 23 void DrawWaiterForTest::WaitForCommit(Compositor* compositor) { | 
| 20   DrawWaiterForTest waiter; | 24   DrawWaiterForTest waiter(WAIT_FOR_COMMIT); | 
| 21   waiter.wait_for_commit_ = true; |  | 
| 22   waiter.WaitImpl(compositor); | 25   waiter.WaitImpl(compositor); | 
| 23 } | 26 } | 
| 24 | 27 | 
| 25 DrawWaiterForTest::DrawWaiterForTest() { | 28 DrawWaiterForTest::DrawWaiterForTest(WaitEvent wait_event) | 
|  | 29     : wait_event_(wait_event) { | 
| 26 } | 30 } | 
| 27 | 31 | 
| 28 DrawWaiterForTest::~DrawWaiterForTest() {} | 32 DrawWaiterForTest::~DrawWaiterForTest() {} | 
| 29 | 33 | 
| 30 void DrawWaiterForTest::WaitImpl(Compositor* compositor) { | 34 void DrawWaiterForTest::WaitImpl(Compositor* compositor) { | 
| 31   compositor->AddObserver(this); | 35   compositor->AddObserver(this); | 
| 32   wait_run_loop_.reset(new base::RunLoop()); | 36   wait_run_loop_.reset(new base::RunLoop()); | 
| 33   wait_run_loop_->Run(); | 37   wait_run_loop_->Run(); | 
| 34   compositor->RemoveObserver(this); | 38   compositor->RemoveObserver(this); | 
| 35 } | 39 } | 
| 36 | 40 | 
| 37 void DrawWaiterForTest::OnCompositingDidCommit(Compositor* compositor) { | 41 void DrawWaiterForTest::OnCompositingDidCommit(Compositor* compositor) { | 
| 38   if (wait_for_commit_) | 42   if (wait_event_ == WAIT_FOR_COMMIT) | 
| 39     wait_run_loop_->Quit(); | 43     wait_run_loop_->Quit(); | 
| 40 } | 44 } | 
| 41 | 45 | 
| 42 void DrawWaiterForTest::OnCompositingStarted(Compositor* compositor, | 46 void DrawWaiterForTest::OnCompositingStarted(Compositor* compositor, | 
| 43                                              base::TimeTicks start_time) { | 47                                              base::TimeTicks start_time) { | 
|  | 48   if (wait_event_ == WAIT_FOR_COMPOSITING_STARTED) | 
|  | 49     wait_run_loop_->Quit(); | 
| 44 } | 50 } | 
| 45 | 51 | 
| 46 void DrawWaiterForTest::OnCompositingEnded(Compositor* compositor) { | 52 void DrawWaiterForTest::OnCompositingEnded(Compositor* compositor) { | 
| 47   if (!wait_for_commit_) | 53   if (wait_event_ == WAIT_FOR_COMPOSITING_ENDED) | 
| 48     wait_run_loop_->Quit(); | 54     wait_run_loop_->Quit(); | 
| 49 } | 55 } | 
| 50 | 56 | 
| 51 void DrawWaiterForTest::OnCompositingAborted(Compositor* compositor) { | 57 void DrawWaiterForTest::OnCompositingAborted(Compositor* compositor) { | 
| 52 } | 58 } | 
| 53 | 59 | 
| 54 void DrawWaiterForTest::OnCompositingLockStateChanged(Compositor* compositor) {} | 60 void DrawWaiterForTest::OnCompositingLockStateChanged(Compositor* compositor) {} | 
| 55 | 61 | 
| 56 void DrawWaiterForTest::OnCompositingShuttingDown(Compositor* compositor) {} | 62 void DrawWaiterForTest::OnCompositingShuttingDown(Compositor* compositor) {} | 
| 57 | 63 | 
| 58 }  // namespace ui | 64 }  // namespace ui | 
| OLD | NEW | 
|---|