| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_task_runner.h" | 5 #include "content/child/worker_task_runner.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 return false; | 32 return false; |
| 33 } | 33 } |
| 34 | 34 |
| 35 bool RunsTasksOnCurrentThread() const override { return false; } | 35 bool RunsTasksOnCurrentThread() const override { return false; } |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 } // namespace | 38 } // namespace |
| 39 | 39 |
| 40 struct WorkerTaskRunner::ThreadLocalState { | 40 struct WorkerTaskRunner::ThreadLocalState { |
| 41 ThreadLocalState() {} | 41 ThreadLocalState() {} |
| 42 ObserverList<WorkerTaskRunner::Observer> stop_observers_; | 42 base::ObserverList<WorkerTaskRunner::Observer> stop_observers_; |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 WorkerTaskRunner::WorkerTaskRunner() | 45 WorkerTaskRunner::WorkerTaskRunner() |
| 46 : task_runner_for_dead_worker_(new DoNothingTaskRunner()) { | 46 : task_runner_for_dead_worker_(new DoNothingTaskRunner()) { |
| 47 } | 47 } |
| 48 | 48 |
| 49 bool WorkerTaskRunner::PostTask( | 49 bool WorkerTaskRunner::PostTask( |
| 50 int id, const base::Closure& closure) { | 50 int id, const base::Closure& closure) { |
| 51 DCHECK(id > 0); | 51 DCHECK(id > 0); |
| 52 base::AutoLock locker(task_runner_map_lock_); | 52 base::AutoLock locker(task_runner_map_lock_); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 current_tls_.Set(NULL); | 111 current_tls_.Set(NULL); |
| 112 } | 112 } |
| 113 | 113 |
| 114 base::TaskRunner* WorkerTaskRunner::GetTaskRunnerFor(int worker_id) { | 114 base::TaskRunner* WorkerTaskRunner::GetTaskRunnerFor(int worker_id) { |
| 115 base::AutoLock locker(task_runner_map_lock_); | 115 base::AutoLock locker(task_runner_map_lock_); |
| 116 return ContainsKey(task_runner_map_, worker_id) ? task_runner_map_[worker_id] | 116 return ContainsKey(task_runner_map_, worker_id) ? task_runner_map_[worker_id] |
| 117 : task_runner_for_dead_worker_.get(); | 117 : task_runner_for_dead_worker_.get(); |
| 118 } | 118 } |
| 119 | 119 |
| 120 } // namespace content | 120 } // namespace content |
| OLD | NEW |