OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 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 "core/workers/WorkerTaskRunners.h" | |
6 | |
7 #include "core/workers/WorkerOrWorkletGlobalScope.h" | |
8 #include "platform/WebTaskRunner.h" | |
9 #include "platform/wtf/Assertions.h" | |
10 #include "public/platform/Platform.h" | |
11 | |
12 namespace blink { | |
13 | |
14 RefPtr<WorkerTaskRunners> WorkerTaskRunners::Create( | |
15 WorkerOrWorkletGlobalScope* global_scope) { | |
16 return AdoptRef(new WorkerTaskRunners(global_scope)); | |
17 } | |
18 | |
19 WorkerTaskRunners::WorkerTaskRunners(WorkerOrWorkletGlobalScope* global_scope) { | |
20 DCHECK(global_scope); | |
21 DCHECK(global_scope->IsContextThread()); | |
22 for (unsigned i = 0; i < static_cast<unsigned>(TaskType::kNumberOfTaskTypes); | |
23 ++i) { | |
24 TaskType type = static_cast<TaskType>(i); | |
25 task_runners_.insert(type, TaskRunnerHelper::Get(type, global_scope)); | |
26 } | |
27 } | |
28 | |
29 RefPtr<WebTaskRunner> WorkerTaskRunners::Get(TaskType type) { | |
30 DCHECK_GT(TaskType::kNumberOfTaskTypes, type); | |
31 return task_runners_.at(type); | |
Sami
2017/04/12 15:54:06
Is there some benefit to caching runners in |task_
kinuko
2017/04/13 01:46:59
Yeah, (in case it wasn't clear) I agree with this
nhiroki
2017/04/13 08:23:50
I removed WorkerTaskRunners. The original motivati
| |
32 } | |
33 | |
34 } // namespace blink | |
OLD | NEW |