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

Side by Side Diff: base/message_loop_unittest.cc

Issue 2822035: Change chrome from statically enabling high resolution timers on windows... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « base/message_loop.cc ('k') | base/test/test_suite.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 (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "base/eintr_wrapper.h" 5 #include "base/eintr_wrapper.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/platform_thread.h" 8 #include "base/platform_thread.h"
9 #include "base/ref_counted.h" 9 #include "base/ref_counted.h"
10 #include "base/task.h" 10 #include "base/task.h"
(...skipping 1521 matching lines...) Expand 10 before | Expand all | Expand 10 after
1532 RunTest_DispatcherWithMessageHook(MessageLoop::TYPE_UI); 1532 RunTest_DispatcherWithMessageHook(MessageLoop::TYPE_UI);
1533 } 1533 }
1534 1534
1535 TEST(MessageLoopTest, IOHandler) { 1535 TEST(MessageLoopTest, IOHandler) {
1536 RunTest_IOHandler(); 1536 RunTest_IOHandler();
1537 } 1537 }
1538 1538
1539 TEST(MessageLoopTest, WaitForIO) { 1539 TEST(MessageLoopTest, WaitForIO) {
1540 RunTest_WaitForIO(); 1540 RunTest_WaitForIO();
1541 } 1541 }
1542
1543 TEST(MessageLoopTest, HighResolutionTimer) {
1544 MessageLoop loop;
1545
1546 const int kFastTimerMs = 5;
1547 const int kSlowTimerMs = 100;
1548
1549 EXPECT_EQ(false, loop.high_resolution_timers_enabled());
1550
1551 // Post a fast task to enable the high resolution timers.
1552 loop.PostDelayedTask(FROM_HERE, new DummyTask(1), kFastTimerMs);
1553 loop.Run();
1554 EXPECT_EQ(true, loop.high_resolution_timers_enabled());
1555
1556 // Post a slow task and verify high resolution timers
1557 // are still enabled.
1558 loop.PostDelayedTask(FROM_HERE, new DummyTask(1), kSlowTimerMs);
1559 loop.Run();
1560 EXPECT_EQ(true, loop.high_resolution_timers_enabled());
1561
1562 // Wait for a while so that high-resolution mode elapses.
1563 Sleep(MessageLoop::kHighResolutionTimerModeLeaseTimeMs);
1564
1565 // Post a slow task to disable the high resolution timers.
1566 loop.PostDelayedTask(FROM_HERE, new DummyTask(1), kSlowTimerMs);
1567 loop.Run();
1568 EXPECT_EQ(false, loop.high_resolution_timers_enabled());
1569 }
1570
1542 #endif // defined(OS_WIN) 1571 #endif // defined(OS_WIN)
1543 1572
1544 #if defined(OS_POSIX) 1573 #if defined(OS_POSIX)
1545 1574
1546 namespace { 1575 namespace {
1547 1576
1548 class QuitDelegate : public base::MessagePumpLibevent::Watcher { 1577 class QuitDelegate : public base::MessagePumpLibevent::Watcher {
1549 public: 1578 public:
1550 virtual void OnFileCanWriteWithoutBlocking(int fd) { 1579 virtual void OnFileCanWriteWithoutBlocking(int fd) {
1551 MessageLoop::current()->Quit(); 1580 MessageLoop::current()->Quit();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1605 } 1634 }
1606 if (HANDLE_EINTR(close(pipefds[0])) < 0) 1635 if (HANDLE_EINTR(close(pipefds[0])) < 0)
1607 PLOG(ERROR) << "close"; 1636 PLOG(ERROR) << "close";
1608 if (HANDLE_EINTR(close(pipefds[1])) < 0) 1637 if (HANDLE_EINTR(close(pipefds[1])) < 0)
1609 PLOG(ERROR) << "close"; 1638 PLOG(ERROR) << "close";
1610 } 1639 }
1611 1640
1612 } // namespace 1641 } // namespace
1613 1642
1614 #endif // defined(OS_POSIX) 1643 #endif // defined(OS_POSIX)
OLDNEW
« no previous file with comments | « base/message_loop.cc ('k') | base/test/test_suite.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698