OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_libevent.h" | 5 #include "base/message_loop/message_pump_libevent.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <unistd.h> | 9 #include <unistd.h> |
10 | 10 |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 } | 295 } |
296 | 296 |
297 void MessagePumpLibevent::ScheduleDelayedWork( | 297 void MessagePumpLibevent::ScheduleDelayedWork( |
298 const TimeTicks& delayed_work_time) { | 298 const TimeTicks& delayed_work_time) { |
299 // We know that we can't be blocked on Wait right now since this method can | 299 // We know that we can't be blocked on Wait right now since this method can |
300 // only be called on the same thread as Run, so we only need to update our | 300 // only be called on the same thread as Run, so we only need to update our |
301 // record of how long to sleep when we do sleep. | 301 // record of how long to sleep when we do sleep. |
302 delayed_work_time_ = delayed_work_time; | 302 delayed_work_time_ = delayed_work_time; |
303 } | 303 } |
304 | 304 |
305 void MessagePumpLibevent::Shutdown() { | |
306 } | |
307 | |
308 void MessagePumpLibevent::WillProcessIOEvent() { | 305 void MessagePumpLibevent::WillProcessIOEvent() { |
309 FOR_EACH_OBSERVER(IOObserver, io_observers_, WillProcessIOEvent()); | 306 FOR_EACH_OBSERVER(IOObserver, io_observers_, WillProcessIOEvent()); |
310 } | 307 } |
311 | 308 |
312 void MessagePumpLibevent::DidProcessIOEvent() { | 309 void MessagePumpLibevent::DidProcessIOEvent() { |
313 FOR_EACH_OBSERVER(IOObserver, io_observers_, DidProcessIOEvent()); | 310 FOR_EACH_OBSERVER(IOObserver, io_observers_, DidProcessIOEvent()); |
314 } | 311 } |
315 | 312 |
316 bool MessagePumpLibevent::Init() { | 313 bool MessagePumpLibevent::Init() { |
317 int fds[2]; | 314 int fds[2]; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 // Remove and discard the wakeup byte. | 366 // Remove and discard the wakeup byte. |
370 char buf; | 367 char buf; |
371 int nread = HANDLE_EINTR(read(socket, &buf, 1)); | 368 int nread = HANDLE_EINTR(read(socket, &buf, 1)); |
372 DCHECK_EQ(nread, 1); | 369 DCHECK_EQ(nread, 1); |
373 that->processed_io_events_ = true; | 370 that->processed_io_events_ = true; |
374 // Tell libevent to break out of inner loop. | 371 // Tell libevent to break out of inner loop. |
375 event_base_loopbreak(that->event_base_); | 372 event_base_loopbreak(that->event_base_); |
376 } | 373 } |
377 | 374 |
378 } // namespace base | 375 } // namespace base |
OLD | NEW |