summaryrefslogtreecommitdiff
path: root/shill_event.cc
blob: 9fb8d5c5c5650607ed8f0ea78bbce6307bb3ec8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <stdio.h>
#include <glib.h>

#include <base/callback_old.h>
#include <base/message_loop_proxy.h>

#include "shill/glib_io_handler.h"
#include "shill/shill_event.h"

namespace shill {

EventDispatcher::EventDispatcher()
    : dont_use_directly_(new MessageLoopForUI),
      message_loop_proxy_(base::MessageLoopProxy::CreateForCurrentThread()) {
}

EventDispatcher::~EventDispatcher() {}

void EventDispatcher::DispatchForever() {
  MessageLoop::current()->Run();
}

bool EventDispatcher::PostTask(Task* task) {
  return message_loop_proxy_->PostTask(FROM_HERE, task);
}

bool EventDispatcher::PostDelayedTask(Task* task, int64 delay_ms) {
  return message_loop_proxy_->PostDelayedTask(FROM_HERE, task, delay_ms);
}

IOInputHandler *EventDispatcher::CreateInputHandler(
    int fd,
    Callback1<InputData*>::Type *callback) {
  return new GlibIOInputHandler(fd, callback);
}

}  // namespace shill