Home | History | Annotate | Download | only in child
      1 // Copyright 2013 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 "content/child/worker_thread_task_runner.h"
      6 
      7 #include "base/logging.h"
      8 #include "content/child/worker_task_runner.h"
      9 
     10 namespace content {
     11 
     12 WorkerThreadTaskRunner::WorkerThreadTaskRunner(int worker_thread_id)
     13     : worker_thread_id_(worker_thread_id) {
     14 }
     15 
     16 scoped_refptr<WorkerThreadTaskRunner> WorkerThreadTaskRunner::current() {
     17   int worker_thread_id = WorkerTaskRunner::Instance()->CurrentWorkerId();
     18   if (!worker_thread_id)
     19     return scoped_refptr<WorkerThreadTaskRunner>();
     20   return make_scoped_refptr(new WorkerThreadTaskRunner(worker_thread_id));
     21 }
     22 
     23 bool WorkerThreadTaskRunner::PostDelayedTask(
     24     const tracked_objects::Location& /* from_here */,
     25     const base::Closure& task,
     26     base::TimeDelta delay) {
     27   // Currently non-zero delay is not supported.
     28   DCHECK(!delay.ToInternalValue());
     29   return WorkerTaskRunner::Instance()->PostTask(worker_thread_id_, task);
     30 }
     31 
     32 bool WorkerThreadTaskRunner::RunsTasksOnCurrentThread() const {
     33   return worker_thread_id_ == WorkerTaskRunner::Instance()->CurrentWorkerId();
     34 }
     35 
     36 WorkerThreadTaskRunner::~WorkerThreadTaskRunner() {}
     37 
     38 }  // namespace content
     39