Home | History | Annotate | Download | only in base
      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.
      4 
      5 #include "remoting/base/auto_thread_task_runner.h"
      6 
      7 #include "base/logging.h"
      8 
      9 namespace remoting {
     10 
     11 AutoThreadTaskRunner::AutoThreadTaskRunner(
     12     scoped_refptr<base::SingleThreadTaskRunner> task_runner,
     13     const base::Closure& stop_task)
     14     : stop_task_(stop_task),
     15       task_runner_(task_runner) {
     16   DCHECK(!stop_task_.is_null());
     17 }
     18 
     19 bool AutoThreadTaskRunner::PostDelayedTask(
     20     const tracked_objects::Location& from_here,
     21     const base::Closure& task,
     22     base::TimeDelta delay) {
     23   CHECK(task_runner_->PostDelayedTask(from_here, task, delay));
     24   return true;
     25 }
     26 
     27 bool AutoThreadTaskRunner::PostNonNestableDelayedTask(
     28     const tracked_objects::Location& from_here,
     29     const base::Closure& task,
     30     base::TimeDelta delay) {
     31   CHECK(task_runner_->PostNonNestableDelayedTask(from_here, task, delay));
     32   return true;
     33 }
     34 
     35 bool AutoThreadTaskRunner::RunsTasksOnCurrentThread() const {
     36   return task_runner_->RunsTasksOnCurrentThread();
     37 }
     38 
     39 AutoThreadTaskRunner::~AutoThreadTaskRunner() {
     40   CHECK(task_runner_->PostTask(FROM_HERE, stop_task_));
     41 }
     42 
     43 }  // namespace remoting
     44