• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "webkit/child/worker_task_runner.h"
9 
10 using webkit_glue::WorkerTaskRunner;
11 
12 namespace content {
13 
WorkerThreadTaskRunner(int worker_thread_id)14 WorkerThreadTaskRunner::WorkerThreadTaskRunner(int worker_thread_id)
15     : worker_thread_id_(worker_thread_id) {
16 }
17 
current()18 scoped_refptr<WorkerThreadTaskRunner> WorkerThreadTaskRunner::current() {
19   int worker_thread_id = WorkerTaskRunner::Instance()->CurrentWorkerId();
20   if (!worker_thread_id)
21     return scoped_refptr<WorkerThreadTaskRunner>();
22   return make_scoped_refptr(new WorkerThreadTaskRunner(worker_thread_id));
23 }
24 
PostDelayedTask(const tracked_objects::Location &,const base::Closure & task,base::TimeDelta delay)25 bool WorkerThreadTaskRunner::PostDelayedTask(
26     const tracked_objects::Location& /* from_here */,
27     const base::Closure& task,
28     base::TimeDelta delay) {
29   // Currently non-zero delay is not supported.
30   DCHECK(!delay.ToInternalValue());
31   return WorkerTaskRunner::Instance()->PostTask(worker_thread_id_, task);
32 }
33 
RunsTasksOnCurrentThread() const34 bool WorkerThreadTaskRunner::RunsTasksOnCurrentThread() const {
35   return worker_thread_id_ == WorkerTaskRunner::Instance()->CurrentWorkerId();
36 }
37 
~WorkerThreadTaskRunner()38 WorkerThreadTaskRunner::~WorkerThreadTaskRunner() {}
39 
40 }  // namespace content
41