1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
6 #include "base/message_loop/message_loop.h"
7 #include "jingle/glue/task_pump.h"
9 namespace jingle_glue
{
12 : weak_factory_(this),
16 TaskPump::~TaskPump() {
17 DCHECK(CalledOnValidThread());
20 void TaskPump::WakeTasks() {
21 DCHECK(CalledOnValidThread());
22 if (!stopped_
&& !posted_wake_
) {
23 base::MessageLoop
* current_message_loop
= base::MessageLoop::current();
24 CHECK(current_message_loop
);
25 // Do the requested wake up.
26 current_message_loop
->PostTask(
28 base::Bind(&TaskPump::CheckAndRunTasks
, weak_factory_
.GetWeakPtr()));
33 int64
TaskPump::CurrentTime() {
34 DCHECK(CalledOnValidThread());
35 // Only timeout tasks rely on this function. Since we're not using
36 // libjingle tasks for timeout, it's safe to return 0 here.
40 void TaskPump::Stop() {
44 void TaskPump::CheckAndRunTasks() {
45 DCHECK(CalledOnValidThread());
50 // We shouldn't be using libjingle for timeout tasks, so we should
51 // have no timeout tasks at all.
53 // TODO(akalin): Add HasTimeoutTask() back in TaskRunner class and
54 // uncomment this check.
55 // DCHECK(!HasTimeoutTask())
59 } // namespace jingle_glue