blob: bed38c71ee013802e171d4756d4443bb51a005fd [file] [log] [blame]
Paul Stewart75897df2011-04-27 09:05:53 -07001// 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 Masone0e1d1042011-05-09 18:07:03 -070010#include <base/basictypes.h>
Chris Masone487b8bf2011-05-13 16:27:57 -070011#include <base/callback_old.h>
12#include <base/memory/ref_counted.h>
13#include <base/memory/scoped_ptr.h>
Chris Masone0e1d1042011-05-09 18:07:03 -070014#include <base/message_loop.h>
Chris Masone0e1d1042011-05-09 18:07:03 -070015
Paul Stewart25379f12011-05-26 06:41:38 -070016#include "shill/io_handler.h"
17
Chris Masone0e1d1042011-05-09 18:07:03 -070018namespace base {
19class MessageLoopProxy;
20} // namespace base
21class Task;
22
Paul Stewart75897df2011-04-27 09:05:53 -070023namespace shill {
24
Paul Stewart75897df2011-04-27 09:05:53 -070025// 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.
28class EventDispatcher {
29 public:
Chris Masone0e1d1042011-05-09 18:07:03 -070030 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 Stewart75897df2011-04-27 09:05:53 -070041 private:
Chris Masone0e1d1042011-05-09 18:07:03 -070042 scoped_ptr<MessageLoop> dont_use_directly_;
43 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
Paul Stewart75897df2011-04-27 09:05:53 -070044};
45
46} // namespace shill
47
48#endif // SHILL_EVENT_