| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/eintr_wrapper.h" | 7 #include "base/eintr_wrapper.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/ref_counted.h" | 10 #include "base/ref_counted.h" |
| (...skipping 1537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1548 TEST(MessageLoopTest, WaitForIO) { | 1548 TEST(MessageLoopTest, WaitForIO) { |
| 1549 RunTest_WaitForIO(); | 1549 RunTest_WaitForIO(); |
| 1550 } | 1550 } |
| 1551 | 1551 |
| 1552 TEST(MessageLoopTest, HighResolutionTimer) { | 1552 TEST(MessageLoopTest, HighResolutionTimer) { |
| 1553 MessageLoop loop; | 1553 MessageLoop loop; |
| 1554 | 1554 |
| 1555 const int kFastTimerMs = 5; | 1555 const int kFastTimerMs = 5; |
| 1556 const int kSlowTimerMs = 100; | 1556 const int kSlowTimerMs = 100; |
| 1557 | 1557 |
| 1558 EXPECT_EQ(false, loop.high_resolution_timers_enabled()); | 1558 EXPECT_FALSE(loop.high_resolution_timers_enabled()); |
| 1559 | 1559 |
| 1560 // Post a fast task to enable the high resolution timers. | 1560 // Post a fast task to enable the high resolution timers. |
| 1561 loop.PostDelayedTask(FROM_HERE, new DummyTask(1), kFastTimerMs); | 1561 loop.PostDelayedTask(FROM_HERE, new DummyTask(1), kFastTimerMs); |
| 1562 loop.Run(); | 1562 loop.Run(); |
| 1563 EXPECT_EQ(true, loop.high_resolution_timers_enabled()); | 1563 EXPECT_TRUE(loop.high_resolution_timers_enabled()); |
| 1564 | 1564 |
| 1565 // Post a slow task and verify high resolution timers | 1565 // Post a slow task and verify high resolution timers |
| 1566 // are still enabled. | 1566 // are still enabled. |
| 1567 loop.PostDelayedTask(FROM_HERE, new DummyTask(1), kSlowTimerMs); | 1567 loop.PostDelayedTask(FROM_HERE, new DummyTask(1), kSlowTimerMs); |
| 1568 loop.Run(); | 1568 loop.Run(); |
| 1569 EXPECT_EQ(true, loop.high_resolution_timers_enabled()); | 1569 EXPECT_TRUE(loop.high_resolution_timers_enabled()); |
| 1570 | 1570 |
| 1571 // Wait for a while so that high-resolution mode elapses. | 1571 // Wait for a while so that high-resolution mode elapses. |
| 1572 Sleep(MessageLoop::kHighResolutionTimerModeLeaseTimeMs); | 1572 Sleep(MessageLoop::kHighResolutionTimerModeLeaseTimeMs); |
| 1573 | 1573 |
| 1574 // Post a slow task to disable the high resolution timers. | 1574 // Post a slow task to disable the high resolution timers. |
| 1575 loop.PostDelayedTask(FROM_HERE, new DummyTask(1), kSlowTimerMs); | 1575 loop.PostDelayedTask(FROM_HERE, new DummyTask(1), kSlowTimerMs); |
| 1576 loop.Run(); | 1576 loop.Run(); |
| 1577 EXPECT_EQ(false, loop.high_resolution_timers_enabled()); | 1577 EXPECT_FALSE(loop.high_resolution_timers_enabled()); |
| 1578 } | 1578 } |
| 1579 | 1579 |
| 1580 #endif // defined(OS_WIN) | 1580 #endif // defined(OS_WIN) |
| 1581 | 1581 |
| 1582 #if defined(OS_POSIX) && !defined(OS_NACL) | 1582 #if defined(OS_POSIX) && !defined(OS_NACL) |
| 1583 | 1583 |
| 1584 namespace { | 1584 namespace { |
| 1585 | 1585 |
| 1586 class QuitDelegate : public base::MessagePumpLibevent::Watcher { | 1586 class QuitDelegate : public base::MessagePumpLibevent::Watcher { |
| 1587 public: | 1587 public: |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1707 loop->PostDelayedTask( | 1707 loop->PostDelayedTask( |
| 1708 FROM_HERE, | 1708 FROM_HERE, |
| 1709 new RunAtDestructionTask(&task_destroyed, &destruction_observer_called), | 1709 new RunAtDestructionTask(&task_destroyed, &destruction_observer_called), |
| 1710 kDelayMS); | 1710 kDelayMS); |
| 1711 delete loop; | 1711 delete loop; |
| 1712 EXPECT_TRUE(observer.task_destroyed_before_message_loop()); | 1712 EXPECT_TRUE(observer.task_destroyed_before_message_loop()); |
| 1713 // The task should have been destroyed when we deleted the loop. | 1713 // The task should have been destroyed when we deleted the loop. |
| 1714 EXPECT_TRUE(task_destroyed); | 1714 EXPECT_TRUE(task_destroyed); |
| 1715 EXPECT_TRUE(destruction_observer_called); | 1715 EXPECT_TRUE(destruction_observer_called); |
| 1716 } | 1716 } |
| OLD | NEW |