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 | |
Paul Stewart | 25379f1 | 2011-05-26 06:41:38 -0700 | [diff] [blame] | 16 | #include "shill/io_handler.h" |
| 17 | |
Chris Masone | 0e1d104 | 2011-05-09 18:07:03 -0700 | [diff] [blame] | 18 | namespace base { |
| 19 | class MessageLoopProxy; |
| 20 | } // namespace base |
| 21 | class Task; |
| 22 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 23 | namespace shill { |
| 24 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 25 | // This is the main event dispatcher. It contains a central instance, and |
| 26 | // is the entity responsible for dispatching events out of all queues to |
| 27 | // their listeners during the idle loop. |
| 28 | class EventDispatcher { |
| 29 | public: |
Chris Masone | 0e1d104 | 2011-05-09 18:07:03 -0700 | [diff] [blame] | 30 | EventDispatcher(); |
| 31 | virtual ~EventDispatcher(); |
| 32 | void DispatchForever(); |
| 33 | |
| 34 | // These are thin wrappers around calls of the same name in |
| 35 | // <base/message_loop_proxy.h> |
| 36 | bool PostTask(Task* task); |
| 37 | bool PostDelayedTask(Task* task, int64 delay_ms); |
| 38 | |
| 39 | IOInputHandler *CreateInputHandler(int fd, |
| 40 | Callback1<InputData*>::Type *callback); |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 41 | private: |
Chris Masone | 0e1d104 | 2011-05-09 18:07:03 -0700 | [diff] [blame] | 42 | scoped_ptr<MessageLoop> dont_use_directly_; |
| 43 | scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | } // namespace shill |
| 47 | |
| 48 | #endif // SHILL_EVENT_ |