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

Side by Side Diff: base/message_loop_unittest.cc

Issue 2825006: Revert 49982 - patch (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 6 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/logging.h ('k') | base/message_pump_libevent.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 (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 1560 matching lines...) Expand 10 before | Expand all | Expand 10 after
1571 base::MessagePumpLibevent::FileDescriptorWatcher controller; 1571 base::MessagePumpLibevent::FileDescriptorWatcher controller;
1572 { 1572 {
1573 MessageLoopForIO message_loop; 1573 MessageLoopForIO message_loop;
1574 1574
1575 QuitDelegate delegate; 1575 QuitDelegate delegate;
1576 message_loop.WatchFileDescriptor(fd, 1576 message_loop.WatchFileDescriptor(fd,
1577 true, MessageLoopForIO::WATCH_WRITE, &controller, &delegate); 1577 true, MessageLoopForIO::WATCH_WRITE, &controller, &delegate);
1578 // and don't run the message loop, just destroy it. 1578 // and don't run the message loop, just destroy it.
1579 } 1579 }
1580 } 1580 }
1581 if (HANDLE_EINTR(close(pipefds[0])) < 0) 1581 HANDLE_EINTR(close(pipefds[0]));
1582 PLOG(WARNING) << "close"; 1582 HANDLE_EINTR(close(pipefds[1]));
1583 if (HANDLE_EINTR(close(pipefds[1])) < 0)
1584 PLOG(WARNING) << "close";
1585 } 1583 }
1586 1584
1587 TEST(MessageLoopTest, FileDescriptorWatcherDoubleStop) { 1585 TEST(MessageLoopTest, FileDescriptorWatcherDoubleStop) {
1588 // Verify that it's ok to call StopWatchingFileDescriptor(). 1586 // Verify that it's ok to call StopWatchingFileDescriptor().
1589 // (Errors only showed up in valgrind.) 1587 // (Errors only showed up in valgrind.)
1590 int pipefds[2]; 1588 int pipefds[2];
1591 int err = pipe(pipefds); 1589 int err = pipe(pipefds);
1592 ASSERT_TRUE(err == 0); 1590 ASSERT_TRUE(err == 0);
1593 int fd = pipefds[1]; 1591 int fd = pipefds[1];
1594 { 1592 {
1595 // Arrange for message loop to live longer than controller. 1593 // Arrange for message loop to live longer than controller.
1596 MessageLoopForIO message_loop; 1594 MessageLoopForIO message_loop;
1597 { 1595 {
1598 base::MessagePumpLibevent::FileDescriptorWatcher controller; 1596 base::MessagePumpLibevent::FileDescriptorWatcher controller;
1599 1597
1600 QuitDelegate delegate; 1598 QuitDelegate delegate;
1601 message_loop.WatchFileDescriptor(fd, 1599 message_loop.WatchFileDescriptor(fd,
1602 true, MessageLoopForIO::WATCH_WRITE, &controller, &delegate); 1600 true, MessageLoopForIO::WATCH_WRITE, &controller, &delegate);
1603 controller.StopWatchingFileDescriptor(); 1601 controller.StopWatchingFileDescriptor();
1604 } 1602 }
1605 } 1603 }
1606 if (HANDLE_EINTR(close(pipefds[0])) < 0) 1604 HANDLE_EINTR(close(pipefds[0]));
1607 PLOG(WARNING) << "close"; 1605 HANDLE_EINTR(close(pipefds[1]));
1608 if (HANDLE_EINTR(close(pipefds[1])) < 0)
1609 PLOG(WARNING) << "close";
1610 } 1606 }
1611 1607
1612 } // namespace 1608 } // namespace
1613 1609
1614 #endif // defined(OS_POSIX) 1610 #endif // defined(OS_POSIX)
OLDNEW
« no previous file with comments | « base/logging.h ('k') | base/message_pump_libevent.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698