| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "core/workers/ParentFrameTaskRunners.h" | 5 #include "core/workers/ParentFrameTaskRunners.h" |
| 6 | 6 |
| 7 #include "core/dom/ContextLifecycleObserver.h" | 7 #include "core/dom/ContextLifecycleObserver.h" |
| 8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
| 9 #include "public/platform/Platform.h" | 9 #include "public/platform/Platform.h" |
| 10 #include "wtf/Assertions.h" | 10 #include "wtf/Assertions.h" |
| 11 #include "wtf/ThreadingPrimitives.h" | 11 #include "wtf/ThreadingPrimitives.h" |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 ParentFrameTaskRunners::ParentFrameTaskRunners(LocalFrame* frame) | 15 ParentFrameTaskRunners::ParentFrameTaskRunners(LocalFrame* frame) |
| 16 : LocalFrameLifecycleObserver(frame) | 16 : LocalFrameLifecycleObserver(frame) |
| 17 { | 17 { |
| 18 if (frame) | 18 if (frame) |
| 19 DCHECK(frame->document()->isContextThread()); | 19 DCHECK(frame->document()->isContextThread()); |
| 20 | 20 |
| 21 // For now we only support very limited task types. | 21 // For now we only support very limited task types. |
| 22 for (auto type : { TaskType::Internal, TaskType::Networking, TaskType::Poste
dMessage }) { | 22 for (auto type : { TaskType::Internal, TaskType::Networking, TaskType::Poste
dMessage, TaskType::CanvasBlobSerialization }) { |
| 23 m_taskRunners.add(type, TaskRunnerHelper::get(type, frame)); | 23 m_taskRunners.add(type, TaskRunnerHelper::get(type, frame)); |
| 24 } | 24 } |
| 25 } | 25 } |
| 26 | 26 |
| 27 WebTaskRunner* ParentFrameTaskRunners::get(TaskType type) | 27 WebTaskRunner* ParentFrameTaskRunners::get(TaskType type) |
| 28 { | 28 { |
| 29 MutexLocker lock(m_taskRunnersMutex); | 29 MutexLocker lock(m_taskRunnersMutex); |
| 30 return m_taskRunners.get(type); | 30 return m_taskRunners.get(type); |
| 31 } | 31 } |
| 32 | 32 |
| 33 DEFINE_TRACE(ParentFrameTaskRunners) | 33 DEFINE_TRACE(ParentFrameTaskRunners) |
| 34 { | 34 { |
| 35 LocalFrameLifecycleObserver::trace(visitor); | 35 LocalFrameLifecycleObserver::trace(visitor); |
| 36 } | 36 } |
| 37 | 37 |
| 38 void ParentFrameTaskRunners::contextDestroyed() | 38 void ParentFrameTaskRunners::contextDestroyed() |
| 39 { | 39 { |
| 40 MutexLocker lock(m_taskRunnersMutex); | 40 MutexLocker lock(m_taskRunnersMutex); |
| 41 for (auto& entry : m_taskRunners) | 41 for (auto& entry : m_taskRunners) |
| 42 entry.value = Platform::current()->currentThread()->getWebTaskRunner(); | 42 entry.value = Platform::current()->currentThread()->getWebTaskRunner(); |
| 43 } | 43 } |
| 44 | 44 |
| 45 } // namespace blink | 45 } // namespace blink |
| OLD | NEW |