| Index: third_party/WebKit/Source/core/workers/ParentFrameTaskRunners.cpp
|
| diff --git a/third_party/WebKit/Source/core/workers/ParentFrameTaskRunners.cpp b/third_party/WebKit/Source/core/workers/ParentFrameTaskRunners.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..34f51a73ededda32b926d33ebf6f6929a16dc25f
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/core/workers/ParentFrameTaskRunners.cpp
|
| @@ -0,0 +1,45 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "core/workers/ParentFrameTaskRunners.h"
|
| +
|
| +#include "core/dom/ContextLifecycleObserver.h"
|
| +#include "core/dom/Document.h"
|
| +#include "public/platform/Platform.h"
|
| +#include "wtf/Assertions.h"
|
| +#include "wtf/ThreadingPrimitives.h"
|
| +
|
| +namespace blink {
|
| +
|
| +ParentFrameTaskRunners::ParentFrameTaskRunners(LocalFrame* frame)
|
| + : LocalFrameLifecycleObserver(frame)
|
| +{
|
| + if (frame)
|
| + DCHECK(frame->document()->isContextThread());
|
| +
|
| + // For now we only support very limited task types.
|
| + for (auto type : { TaskType::Internal, TaskType::Networking, TaskType::PostedMessage }) {
|
| + m_taskRunners.add(type, TaskRunnerHelper::get(type, frame));
|
| + }
|
| +}
|
| +
|
| +WebTaskRunner* ParentFrameTaskRunners::get(TaskType type)
|
| +{
|
| + MutexLocker lock(m_taskRunnersMutex);
|
| + return m_taskRunners.get(type);
|
| +}
|
| +
|
| +DEFINE_TRACE(ParentFrameTaskRunners)
|
| +{
|
| + LocalFrameLifecycleObserver::trace(visitor);
|
| +}
|
| +
|
| +void ParentFrameTaskRunners::contextDestroyed()
|
| +{
|
| + MutexLocker lock(m_taskRunnersMutex);
|
| + for (auto& entry : m_taskRunners)
|
| + entry.value = Platform::current()->currentThread()->getWebTaskRunner();
|
| +}
|
| +
|
| +} // namespace blink
|
|
|