| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/message_loop/message_pump_io_ios.h" | 5 #include "base/message_loop/message_pump_io_ios.h" |
| 6 | 6 |
| 7 #include <unistd.h> | 7 #include <unistd.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 // Test to make sure that we catch calling WatchFileDescriptor off of the wrong | 76 // Test to make sure that we catch calling WatchFileDescriptor off of the wrong |
| 77 // thread. | 77 // thread. |
| 78 TEST_F(MessagePumpIOSForIOTest, TestWatchingFromBadThread) { | 78 TEST_F(MessagePumpIOSForIOTest, TestWatchingFromBadThread) { |
| 79 MessagePumpIOSForIO::FileDescriptorWatcher watcher; | 79 MessagePumpIOSForIO::FileDescriptorWatcher watcher; |
| 80 StupidWatcher delegate; | 80 StupidWatcher delegate; |
| 81 | 81 |
| 82 ASSERT_DCHECK_DEATH( | 82 ASSERT_DCHECK_DEATH( |
| 83 io_loop()->WatchFileDescriptor(STDOUT_FILENO, false, | 83 io_loop()->WatchFileDescriptor(STDOUT_FILENO, false, |
| 84 MessageLoopForIO::WATCH_READ, &watcher, | 84 MessageLoopForIO::WATCH_READ, &watcher, |
| 85 &delegate), | 85 &delegate)); |
| 86 "Check failed: " | |
| 87 "watch_file_descriptor_caller_checker_.CalledOnValidThread\\(\\)"); | |
| 88 } | 86 } |
| 89 | 87 |
| 90 class BaseWatcher : public MessagePumpIOSForIO::Watcher { | 88 class BaseWatcher : public MessagePumpIOSForIO::Watcher { |
| 91 public: | 89 public: |
| 92 BaseWatcher(MessagePumpIOSForIO::FileDescriptorWatcher* controller) | 90 BaseWatcher(MessagePumpIOSForIO::FileDescriptorWatcher* controller) |
| 93 : controller_(controller) { | 91 : controller_(controller) { |
| 94 DCHECK(controller_); | 92 DCHECK(controller_); |
| 95 } | 93 } |
| 96 ~BaseWatcher() override {} | 94 ~BaseWatcher() override {} |
| 97 | 95 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 pump->WatchFileDescriptor(pipefds_[1], | 171 pump->WatchFileDescriptor(pipefds_[1], |
| 174 false, MessagePumpIOSForIO::WATCH_READ_WRITE, &watcher, &delegate); | 172 false, MessagePumpIOSForIO::WATCH_READ_WRITE, &watcher, &delegate); |
| 175 | 173 |
| 176 // Spoof a callback. | 174 // Spoof a callback. |
| 177 HandleFdIOEvent(&watcher); | 175 HandleFdIOEvent(&watcher); |
| 178 } | 176 } |
| 179 | 177 |
| 180 } // namespace | 178 } // namespace |
| 181 | 179 |
| 182 } // namespace base | 180 } // namespace base |
| OLD | NEW |