blob: 22618bfc5ebcfcbb57cf5708a34025ba9c5d7e5f [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 "mist/event_dispatcher.h"
#include <utility>
#include <base/check_op.h>
#include <base/location.h>
#include <base/logging.h>
#include <base/run_loop.h>
#include <base/strings/stringprintf.h>
#include <base/threading/thread_task_runner_handle.h>
namespace mist {
EventDispatcher::EventDispatcher()
: task_runner_(base::ThreadTaskRunnerHandle::Get()) {}
EventDispatcher::~EventDispatcher() = default;
void EventDispatcher::DispatchForever() {
base::RunLoop run_loop;
quit_closure_ = run_loop.QuitWhenIdleClosure();
run_loop.Run();
}
void EventDispatcher::Stop() {
task_runner_->PostTask(FROM_HERE, std::move(quit_closure_));
}
bool EventDispatcher::PostTask(base::OnceClosure task) {
return task_runner_->PostTask(FROM_HERE, std::move(task));
}
bool EventDispatcher::PostDelayedTask(base::OnceClosure task,
const base::TimeDelta& delay) {
return task_runner_->PostDelayedTask(FROM_HERE, std::move(task), delay);
}
} // namespace mist