OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/child/worker_thread_task_runner.h" | 5 #include "content/child/worker_thread_task_runner.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "content/child/worker_task_runner.h" | 8 #include "content/child/worker_task_runner.h" |
9 | 9 |
10 namespace content { | 10 namespace content { |
11 | 11 |
12 WorkerThreadTaskRunner::WorkerThreadTaskRunner(int worker_thread_id) | 12 WorkerThreadTaskRunner::WorkerThreadTaskRunner(int worker_thread_id) |
13 : worker_thread_id_(worker_thread_id) { | 13 : worker_thread_id_(worker_thread_id) { |
14 } | 14 } |
15 | 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( | 16 bool WorkerThreadTaskRunner::PostDelayedTask( |
24 const tracked_objects::Location& /* from_here */, | 17 const tracked_objects::Location& /* from_here */, |
25 const base::Closure& task, | 18 const base::Closure& task, |
26 base::TimeDelta delay) { | 19 base::TimeDelta delay) { |
27 // Currently non-zero delay is not supported. | 20 // Currently non-zero delay is not supported. |
28 DCHECK(!delay.ToInternalValue()); | 21 DCHECK(!delay.ToInternalValue()); |
29 return WorkerTaskRunner::Instance()->PostTask(worker_thread_id_, task); | 22 return WorkerTaskRunner::Instance()->PostTask(worker_thread_id_, task); |
30 } | 23 } |
31 | 24 |
32 bool WorkerThreadTaskRunner::RunsTasksOnCurrentThread() const { | 25 bool WorkerThreadTaskRunner::RunsTasksOnCurrentThread() const { |
33 return worker_thread_id_ == WorkerTaskRunner::Instance()->CurrentWorkerId(); | 26 return worker_thread_id_ == WorkerTaskRunner::Instance()->CurrentWorkerId(); |
34 } | 27 } |
35 | 28 |
36 WorkerThreadTaskRunner::~WorkerThreadTaskRunner() {} | 29 WorkerThreadTaskRunner::~WorkerThreadTaskRunner() {} |
37 | 30 |
38 } // namespace content | 31 } // namespace content |
OLD | NEW |