Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 1 | // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef SHILL_EVENT_ |
| 6 | #define SHILL_EVENT_ |
| 7 | |
| 8 | #include <vector> |
| 9 | |
Chris Masone | 0e1d104 | 2011-05-09 18:07:03 -0700 | [diff] [blame] | 10 | #include <base/basictypes.h> |
Chris Masone | 487b8bf | 2011-05-13 16:27:57 -0700 | [diff] [blame^] | 11 | #include <base/callback_old.h> |
| 12 | #include <base/memory/ref_counted.h> |
| 13 | #include <base/memory/scoped_ptr.h> |
Chris Masone | 0e1d104 | 2011-05-09 18:07:03 -0700 | [diff] [blame] | 14 | #include <base/message_loop.h> |
Chris Masone | 0e1d104 | 2011-05-09 18:07:03 -0700 | [diff] [blame] | 15 | |
| 16 | namespace base { |
| 17 | class MessageLoopProxy; |
| 18 | } // namespace base |
| 19 | class Task; |
| 20 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 21 | namespace shill { |
| 22 | |
Paul Stewart | a43d923 | 2011-05-10 11:40:22 -0700 | [diff] [blame] | 23 | struct InputData { |
| 24 | unsigned char *buf; |
| 25 | size_t len; |
| 26 | }; |
| 27 | |
| 28 | class IOInputHandler { |
| 29 | public: |
| 30 | IOInputHandler() {} |
| 31 | virtual ~IOInputHandler() {} |
| 32 | }; |
| 33 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 34 | // This is the main event dispatcher. It contains a central instance, and |
| 35 | // is the entity responsible for dispatching events out of all queues to |
| 36 | // their listeners during the idle loop. |
| 37 | class EventDispatcher { |
| 38 | public: |
Chris Masone | 0e1d104 | 2011-05-09 18:07:03 -0700 | [diff] [blame] | 39 | EventDispatcher(); |
| 40 | virtual ~EventDispatcher(); |
| 41 | void DispatchForever(); |
| 42 | |
| 43 | // These are thin wrappers around calls of the same name in |
| 44 | // <base/message_loop_proxy.h> |
| 45 | bool PostTask(Task* task); |
| 46 | bool PostDelayedTask(Task* task, int64 delay_ms); |
| 47 | |
| 48 | IOInputHandler *CreateInputHandler(int fd, |
| 49 | Callback1<InputData*>::Type *callback); |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 50 | private: |
Chris Masone | 0e1d104 | 2011-05-09 18:07:03 -0700 | [diff] [blame] | 51 | scoped_ptr<MessageLoop> dont_use_directly_; |
| 52 | scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | } // namespace shill |
| 56 | |
| 57 | #endif // SHILL_EVENT_ |