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.
5 #include "content/child/worker_thread_task_runner.h"
7 #include "base/logging.h"
8 #include "content/child/worker_task_runner.h"
12 WorkerThreadTaskRunner::WorkerThreadTaskRunner(int worker_thread_id
)
13 : worker_thread_id_(worker_thread_id
) {
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
));
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
);
32 bool WorkerThreadTaskRunner::RunsTasksOnCurrentThread() const {
33 return worker_thread_id_
== WorkerTaskRunner::Instance()->CurrentWorkerId();
36 WorkerThreadTaskRunner::~WorkerThreadTaskRunner() {}
38 } // namespace content