-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevent_dispatcher.cc
42 lines (31 loc) · 1.13 KB
/
event_dispatcher.cc
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
42
// Copyright 2013 The ChromiumOS Authors
// 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/task/single_thread_task_runner.h>
namespace mist {
EventDispatcher::EventDispatcher()
: task_runner_(base::SingleThreadTaskRunner::GetCurrentDefault()) {}
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