| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_pump_libevent.h" | 5 #include "base/message_pump_libevent.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 if (event_add(wakeup_event_, 0)) | 153 if (event_add(wakeup_event_, 0)) |
| 154 return false; | 154 return false; |
| 155 return true; | 155 return true; |
| 156 } | 156 } |
| 157 | 157 |
| 158 MessagePumpLibevent::~MessagePumpLibevent() { | 158 MessagePumpLibevent::~MessagePumpLibevent() { |
| 159 DCHECK(wakeup_event_); | 159 DCHECK(wakeup_event_); |
| 160 DCHECK(event_base_); | 160 DCHECK(event_base_); |
| 161 event_del(wakeup_event_); | 161 event_del(wakeup_event_); |
| 162 delete wakeup_event_; | 162 delete wakeup_event_; |
| 163 if (wakeup_pipe_in_ >= 0) | 163 if (wakeup_pipe_in_ >= 0) { |
| 164 HANDLE_EINTR(close(wakeup_pipe_in_)); | 164 if (HANDLE_EINTR(close(wakeup_pipe_in_)) < 0) |
| 165 if (wakeup_pipe_out_ >= 0) | 165 PLOG(ERROR) << "close"; |
| 166 HANDLE_EINTR(close(wakeup_pipe_out_)); | 166 } |
| 167 if (wakeup_pipe_out_ >= 0) { |
| 168 if (HANDLE_EINTR(close(wakeup_pipe_out_)) < 0) |
| 169 PLOG(ERROR) << "close"; |
| 170 } |
| 167 event_base_free(event_base_); | 171 event_base_free(event_base_); |
| 168 } | 172 } |
| 169 | 173 |
| 170 bool MessagePumpLibevent::WatchFileDescriptor(int fd, | 174 bool MessagePumpLibevent::WatchFileDescriptor(int fd, |
| 171 bool persistent, | 175 bool persistent, |
| 172 Mode mode, | 176 Mode mode, |
| 173 FileDescriptorWatcher *controller, | 177 FileDescriptorWatcher *controller, |
| 174 Watcher *delegate) { | 178 Watcher *delegate) { |
| 175 DCHECK_GE(fd, 0); | 179 DCHECK_GE(fd, 0); |
| 176 DCHECK(controller); | 180 DCHECK(controller); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 | 343 |
| 340 void MessagePumpLibevent::WillProcessIOEvent() { | 344 void MessagePumpLibevent::WillProcessIOEvent() { |
| 341 FOR_EACH_OBSERVER(IOObserver, io_observers_, WillProcessIOEvent()); | 345 FOR_EACH_OBSERVER(IOObserver, io_observers_, WillProcessIOEvent()); |
| 342 } | 346 } |
| 343 | 347 |
| 344 void MessagePumpLibevent::DidProcessIOEvent() { | 348 void MessagePumpLibevent::DidProcessIOEvent() { |
| 345 FOR_EACH_OBSERVER(IOObserver, io_observers_, DidProcessIOEvent()); | 349 FOR_EACH_OBSERVER(IOObserver, io_observers_, DidProcessIOEvent()); |
| 346 } | 350 } |
| 347 | 351 |
| 348 } // namespace base | 352 } // namespace base |
| OLD | NEW |