This source file includes following definitions.
- weak_factory_
- WakeTasks
- CurrentTime
- Stop
- CheckAndRunTasks
#include "base/bind.h"
#include "base/message_loop/message_loop.h"
#include "jingle/glue/task_pump.h"
namespace jingle_glue {
TaskPump::TaskPump()
: posted_wake_(false),
stopped_(false),
weak_factory_(this) {
}
TaskPump::~TaskPump() {
DCHECK(CalledOnValidThread());
}
void TaskPump::WakeTasks() {
DCHECK(CalledOnValidThread());
if (!stopped_ && !posted_wake_) {
base::MessageLoop* current_message_loop = base::MessageLoop::current();
CHECK(current_message_loop);
current_message_loop->PostTask(
FROM_HERE,
base::Bind(&TaskPump::CheckAndRunTasks, weak_factory_.GetWeakPtr()));
posted_wake_ = true;
}
}
int64 TaskPump::CurrentTime() {
DCHECK(CalledOnValidThread());
return 0;
}
void TaskPump::Stop() {
stopped_ = true;
}
void TaskPump::CheckAndRunTasks() {
DCHECK(CalledOnValidThread());
if (stopped_) {
return;
}
posted_wake_ = false;
RunTasks();
}
}