OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #ifndef BASE_MESSAGE_PUMP_LIBEVENT_H_ | 5 #ifndef BASE_MESSAGE_PUMP_LIBEVENT_H_ |
6 #define BASE_MESSAGE_PUMP_LIBEVENT_H_ | 6 #define BASE_MESSAGE_PUMP_LIBEVENT_H_ |
7 | 7 |
8 #include "base/message_pump.h" | 8 #include "base/message_pump.h" |
9 #include "base/scoped_ptr.h" | |
10 #include "base/time.h" | 9 #include "base/time.h" |
11 | 10 |
12 // Declare structs we need from libevent.h rather than including it | 11 // Declare structs we need from libevent.h rather than including it |
13 struct event_base; | 12 struct event_base; |
14 struct event; | 13 struct event; |
15 | 14 |
16 namespace base { | 15 namespace base { |
17 | 16 |
18 // Class to monitor sockets and issue callbacks when sockets are ready for I/O | 17 // Class to monitor sockets and issue callbacks when sockets are ready for I/O |
19 // TODO(dkegel): add support for background file IO somehow | 18 // TODO(dkegel): add support for background file IO somehow |
(...skipping 17 matching lines...) Expand all Loading... |
37 // Called by MessagePumpLibevent, ownership of |e| is transferred to this | 36 // Called by MessagePumpLibevent, ownership of |e| is transferred to this |
38 // object. | 37 // object. |
39 void Init(event* e, bool is_persistent); | 38 void Init(event* e, bool is_persistent); |
40 | 39 |
41 // Used by MessagePumpLibevent to take ownership of event_. | 40 // Used by MessagePumpLibevent to take ownership of event_. |
42 event *ReleaseEvent(); | 41 event *ReleaseEvent(); |
43 friend class MessagePumpLibevent; | 42 friend class MessagePumpLibevent; |
44 | 43 |
45 private: | 44 private: |
46 bool is_persistent_; // false if this event is one-shot. | 45 bool is_persistent_; // false if this event is one-shot. |
47 scoped_ptr<event> event_; | 46 event* event_; |
48 DISALLOW_COPY_AND_ASSIGN(FileDescriptorWatcher); | 47 DISALLOW_COPY_AND_ASSIGN(FileDescriptorWatcher); |
49 }; | 48 }; |
50 | 49 |
51 // Used with WatchFileDescptor to asynchronously monitor the I/O readiness of | 50 // Used with WatchFileDescptor to asynchronously monitor the I/O readiness of |
52 // a File Descriptor. | 51 // a File Descriptor. |
53 class Watcher { | 52 class Watcher { |
54 public: | 53 public: |
55 virtual ~Watcher() {} | 54 virtual ~Watcher() {} |
56 // Called from MessageLoop::Run when an FD can be read from/written to | 55 // Called from MessageLoop::Run when an FD can be read from/written to |
57 // without blocking | 56 // without blocking |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 int wakeup_pipe_out_; | 121 int wakeup_pipe_out_; |
123 // ... libevent wrapper for read end | 122 // ... libevent wrapper for read end |
124 event* wakeup_event_; | 123 event* wakeup_event_; |
125 | 124 |
126 DISALLOW_COPY_AND_ASSIGN(MessagePumpLibevent); | 125 DISALLOW_COPY_AND_ASSIGN(MessagePumpLibevent); |
127 }; | 126 }; |
128 | 127 |
129 } // namespace base | 128 } // namespace base |
130 | 129 |
131 #endif // BASE_MESSAGE_PUMP_LIBEVENT_H_ | 130 #endif // BASE_MESSAGE_PUMP_LIBEVENT_H_ |
OLD | NEW |