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 : posted_wake_(false),
17 TaskPump::~TaskPump() {
18 DCHECK(CalledOnValidThread());
21 void TaskPump::WakeTasks() {
22 DCHECK(CalledOnValidThread());
23 if (!stopped_
&& !posted_wake_
) {
24 base::MessageLoop
* current_message_loop
= base::MessageLoop::current();
25 CHECK(current_message_loop
);
26 // Do the requested wake up.
27 current_message_loop
->PostTask(
29 base::Bind(&TaskPump::CheckAndRunTasks
, weak_factory_
.GetWeakPtr()));
34 int64
TaskPump::CurrentTime() {
35 DCHECK(CalledOnValidThread());
36 // Only timeout tasks rely on this function. Since we're not using
37 // libjingle tasks for timeout, it's safe to return 0 here.
41 void TaskPump::Stop() {
45 void TaskPump::CheckAndRunTasks() {
46 DCHECK(CalledOnValidThread());
51 // We shouldn't be using libjingle for timeout tasks, so we should
52 // have no timeout tasks at all.
54 // TODO(akalin): Add HasTimeoutTask() back in TaskRunner class and
55 // uncomment this check.
56 // DCHECK(!HasTimeoutTask())
60 } // namespace jingle_glue