| OLD | NEW |
| 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/logging.h" | 5 #include "base/logging.h" |
| 6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
| 7 #include "base/platform_thread.h" | 7 #include "base/platform_thread.h" |
| 8 #include "base/ref_counted.h" | 8 #include "base/ref_counted.h" |
| 9 #include "base/thread.h" | 9 #include "base/thread.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 1474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1485 virtual void OnFileCanWriteWithoutBlocking(int fd) { | 1485 virtual void OnFileCanWriteWithoutBlocking(int fd) { |
| 1486 MessageLoop::current()->Quit(); | 1486 MessageLoop::current()->Quit(); |
| 1487 } | 1487 } |
| 1488 virtual void OnFileCanReadWithoutBlocking(int fd) { | 1488 virtual void OnFileCanReadWithoutBlocking(int fd) { |
| 1489 MessageLoop::current()->Quit(); | 1489 MessageLoop::current()->Quit(); |
| 1490 } | 1490 } |
| 1491 }; | 1491 }; |
| 1492 | 1492 |
| 1493 } // namespace | 1493 } // namespace |
| 1494 | 1494 |
| 1495 TEST(MessageLoopTest, FileDescriptorWatcherOutlivesMessageLoop) { | 1495 TEST(MessageLoopTest, DISABLED_FileDescriptorWatcherOutlivesMessageLoop) { |
| 1496 // Simulate a MessageLoop that dies before an FileDescriptorWatcher. | 1496 // Simulate a MessageLoop that dies before an FileDescriptorWatcher. |
| 1497 // This could happen when people use the Singleton pattern or atexit. | 1497 // This could happen when people use the Singleton pattern or atexit. |
| 1498 // This is disabled for now because it fails (valgrind shows | 1498 // This is disabled for now because it fails (valgrind shows |
| 1499 // invalid reads), and it's not clear any code relies on this... | 1499 // invalid reads), and it's not clear any code relies on this... |
| 1500 // TODO(dkegel): enable if it turns out we rely on this |
| 1500 | 1501 |
| 1501 // Create a file descriptor. Doesn't need to be readable or writable, | 1502 // Create a file descriptor. Doesn't need to be readable or writable, |
| 1502 // as we don't need to actually get any notifications. | 1503 // as we don't need to actually get any notifications. |
| 1503 // pipe() is just the easiest way to do it. | 1504 // pipe() is just the easiest way to do it. |
| 1504 int pipefds[2]; | 1505 int pipefds[2]; |
| 1505 int err = pipe(pipefds); | 1506 int err = pipe(pipefds); |
| 1506 ASSERT_TRUE(err == 0); | 1507 ASSERT_TRUE(err == 0); |
| 1507 int fd = pipefds[1]; | 1508 int fd = pipefds[1]; |
| 1508 { | 1509 { |
| 1509 // Arrange for controller to live longer than message loop. | 1510 // Arrange for controller to live longer than message loop. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1538 message_loop.WatchFileDescriptor(fd, | 1539 message_loop.WatchFileDescriptor(fd, |
| 1539 true, MessageLoopForIO::WATCH_WRITE, &controller, &delegate); | 1540 true, MessageLoopForIO::WATCH_WRITE, &controller, &delegate); |
| 1540 controller.StopWatchingFileDescriptor(); | 1541 controller.StopWatchingFileDescriptor(); |
| 1541 } | 1542 } |
| 1542 } | 1543 } |
| 1543 close(pipefds[0]); | 1544 close(pipefds[0]); |
| 1544 close(pipefds[1]); | 1545 close(pipefds[1]); |
| 1545 } | 1546 } |
| 1546 | 1547 |
| 1547 #endif // defined(OS_POSIX) | 1548 #endif // defined(OS_POSIX) |
| OLD | NEW |