blob: bbac05d5c41ec991d6ddd9f783593dcbb1de1837 [file] [log] [blame]
// Copyright (c) 2013 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 "wimax_manager/event_dispatcher.h"
#include <base/location.h>
#include <base/threading/thread_task_runner_handle.h>
namespace wimax_manager {
EventDispatcher::EventDispatcher()
: dont_use_directly_(new base::MessageLoopForUI()),
task_runner_(base::ThreadTaskRunnerHandle::Get()) {
}
void EventDispatcher::DispatchForever() {
base::MessageLoop::current()->Run();
}
bool EventDispatcher::PostTask(const base::Closure &task) {
return task_runner_->PostTask(FROM_HERE, task);
}
bool EventDispatcher::PostDelayedTask(
const base::Closure &task, const base::TimeDelta &delay) {
return task_runner_->PostDelayedTask(FROM_HERE, task, delay);
}
void EventDispatcher::Stop() {
base::MessageLoop::current()->PostTask(
FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
}
} // namespace wimax_manager