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 "eintr_wrapper.h" | 10 #include "eintr_wrapper.h" |
11 #include "base/auto_reset.h" | 11 #include "base/auto_reset.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/scoped_nsautorelease_pool.h" | 13 #include "base/scoped_nsautorelease_pool.h" |
14 #include "base/scoped_ptr.h" | 14 #include "base/scoped_ptr.h" |
15 #include "base/time.h" | 15 #include "base/time.h" |
| 16 #if defined(USE_SYSTEM_LIBEVENT) |
| 17 #include <event.h> |
| 18 #else |
16 #include "third_party/libevent/event.h" | 19 #include "third_party/libevent/event.h" |
| 20 #endif |
17 | 21 |
18 // Lifecycle of struct event | 22 // Lifecycle of struct event |
19 // Libevent uses two main data structures: | 23 // Libevent uses two main data structures: |
20 // struct event_base (of which there is one per message pump), and | 24 // struct event_base (of which there is one per message pump), and |
21 // struct event (of which there is roughly one per socket). | 25 // struct event (of which there is roughly one per socket). |
22 // The socket's struct event is created in | 26 // The socket's struct event is created in |
23 // MessagePumpLibevent::WatchFileDescriptor(), | 27 // MessagePumpLibevent::WatchFileDescriptor(), |
24 // is owned by the FileDescriptorWatcher, and is destroyed in | 28 // is owned by the FileDescriptorWatcher, and is destroyed in |
25 // StopWatchingFileDescriptor(). | 29 // StopWatchingFileDescriptor(). |
26 // It is moved into and out of lists in struct event_base by | 30 // It is moved into and out of lists in struct event_base by |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 } | 298 } |
295 | 299 |
296 void MessagePumpLibevent::ScheduleDelayedWork(const Time& delayed_work_time) { | 300 void MessagePumpLibevent::ScheduleDelayedWork(const Time& delayed_work_time) { |
297 // We know that we can't be blocked on Wait right now since this method can | 301 // We know that we can't be blocked on Wait right now since this method can |
298 // only be called on the same thread as Run, so we only need to update our | 302 // only be called on the same thread as Run, so we only need to update our |
299 // record of how long to sleep when we do sleep. | 303 // record of how long to sleep when we do sleep. |
300 delayed_work_time_ = delayed_work_time; | 304 delayed_work_time_ = delayed_work_time; |
301 } | 305 } |
302 | 306 |
303 } // namespace base | 307 } // namespace base |
OLD | NEW |