blob: 2484554695150385e4fa1e0e01df22da12032cf1 [file] [log] [blame]
Darin Petkov633ac6f2011-07-08 13:56:13 -07001// Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
Paul Stewart75897df2011-04-27 09:05:53 -07002// 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();
Darin Petkov633ac6f2011-07-08 13:56:13 -070032
Chris Masone0e1d1042011-05-09 18:07:03 -070033 void DispatchForever();
34
35 // These are thin wrappers around calls of the same name in
36 // <base/message_loop_proxy.h>
37 bool PostTask(Task* task);
38 bool PostDelayedTask(Task* task, int64 delay_ms);
39
Darin Petkov633ac6f2011-07-08 13:56:13 -070040 virtual IOInputHandler *CreateInputHandler(
41 int fd,
42 Callback1<InputData*>::Type *callback);
43
Paul Stewart75897df2011-04-27 09:05:53 -070044 private:
Chris Masone0e1d1042011-05-09 18:07:03 -070045 scoped_ptr<MessageLoop> dont_use_directly_;
46 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
Paul Stewart75897df2011-04-27 09:05:53 -070047};
48
49} // namespace shill
50
51#endif // SHILL_EVENT_