blob: 9fb8d5c5c5650607ed8f0ea78bbce6307bb3ec8d [file] [log] [blame]
Paul Stewart75897df2011-04-27 09:05:53 -07001// Copyright (c) 2011 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#include <stdio.h>
6#include <glib.h>
7
Chris Masone487b8bf2011-05-13 16:27:57 -07008#include <base/callback_old.h>
Chris Masone0e1d1042011-05-09 18:07:03 -07009#include <base/message_loop_proxy.h>
10
Paul Stewart25379f12011-05-26 06:41:38 -070011#include "shill/glib_io_handler.h"
Paul Stewart75897df2011-04-27 09:05:53 -070012#include "shill/shill_event.h"
13
14namespace shill {
15
Chris Masone0e1d1042011-05-09 18:07:03 -070016EventDispatcher::EventDispatcher()
17 : dont_use_directly_(new MessageLoopForUI),
18 message_loop_proxy_(base::MessageLoopProxy::CreateForCurrentThread()) {
19}
Paul Stewarta43d9232011-05-10 11:40:22 -070020
Chris Masone0e1d1042011-05-09 18:07:03 -070021EventDispatcher::~EventDispatcher() {}
22
23void EventDispatcher::DispatchForever() {
24 MessageLoop::current()->Run();
25}
26
27bool EventDispatcher::PostTask(Task* task) {
mukesh agrawalf60e4062011-05-27 13:13:41 -070028 return message_loop_proxy_->PostTask(FROM_HERE, task);
Chris Masone0e1d1042011-05-09 18:07:03 -070029}
30
31bool EventDispatcher::PostDelayedTask(Task* task, int64 delay_ms) {
mukesh agrawalf60e4062011-05-27 13:13:41 -070032 return message_loop_proxy_->PostDelayedTask(FROM_HERE, task, delay_ms);
Chris Masone0e1d1042011-05-09 18:07:03 -070033}
34
35IOInputHandler *EventDispatcher::CreateInputHandler(
36 int fd,
37 Callback1<InputData*>::Type *callback) {
38 return new GlibIOInputHandler(fd, callback);
Paul Stewarta43d9232011-05-10 11:40:22 -070039}
40
Paul Stewart75897df2011-04-27 09:05:53 -070041} // namespace shill