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/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/posix/eintr_wrapper.h" | 10 #include "base/posix/eintr_wrapper.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 Thread::Options options(MessageLoop::TYPE_IO, 0); | 24 Thread::Options options(MessageLoop::TYPE_IO, 0); |
25 ASSERT_TRUE(io_thread_.StartWithOptions(options)); | 25 ASSERT_TRUE(io_thread_.StartWithOptions(options)); |
26 ASSERT_EQ(MessageLoop::TYPE_IO, io_thread_.message_loop()->type()); | 26 ASSERT_EQ(MessageLoop::TYPE_IO, io_thread_.message_loop()->type()); |
27 int ret = pipe(pipefds_); | 27 int ret = pipe(pipefds_); |
28 ASSERT_EQ(0, ret); | 28 ASSERT_EQ(0, ret); |
29 ret = pipe(alternate_pipefds_); | 29 ret = pipe(alternate_pipefds_); |
30 ASSERT_EQ(0, ret); | 30 ASSERT_EQ(0, ret); |
31 } | 31 } |
32 | 32 |
33 virtual void TearDown() OVERRIDE { | 33 virtual void TearDown() OVERRIDE { |
34 if (HANDLE_EINTR(close(pipefds_[0])) < 0) | 34 if (IGNORE_EINTR(close(pipefds_[0])) < 0) |
35 PLOG(ERROR) << "close"; | 35 PLOG(ERROR) << "close"; |
36 if (HANDLE_EINTR(close(pipefds_[1])) < 0) | 36 if (IGNORE_EINTR(close(pipefds_[1])) < 0) |
37 PLOG(ERROR) << "close"; | 37 PLOG(ERROR) << "close"; |
38 } | 38 } |
39 | 39 |
40 MessageLoop* ui_loop() { return &ui_loop_; } | 40 MessageLoop* ui_loop() { return &ui_loop_; } |
41 MessageLoopForIO* io_loop() const { | 41 MessageLoopForIO* io_loop() const { |
42 return static_cast<MessageLoopForIO*>(io_thread_.message_loop()); | 42 return static_cast<MessageLoopForIO*>(io_thread_.message_loop()); |
43 } | 43 } |
44 | 44 |
45 void HandleFdIOEvent(MessageLoopForIO::FileDescriptorWatcher* watcher) { | 45 void HandleFdIOEvent(MessageLoopForIO::FileDescriptorWatcher* watcher) { |
46 MessagePumpIOSForIO::HandleFdIOEvent(watcher->fdref_, | 46 MessagePumpIOSForIO::HandleFdIOEvent(watcher->fdref_, |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 pump->WatchFileDescriptor(pipefds_[1], | 179 pump->WatchFileDescriptor(pipefds_[1], |
180 false, MessagePumpIOSForIO::WATCH_READ_WRITE, &watcher, &delegate); | 180 false, MessagePumpIOSForIO::WATCH_READ_WRITE, &watcher, &delegate); |
181 | 181 |
182 // Spoof a callback. | 182 // Spoof a callback. |
183 HandleFdIOEvent(&watcher); | 183 HandleFdIOEvent(&watcher); |
184 } | 184 } |
185 | 185 |
186 } // namespace | 186 } // namespace |
187 | 187 |
188 } // namespace base | 188 } // namespace base |
OLD | NEW |