Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: third_party/WebKit/Source/core/workers/ParentFrameTaskRunners.cpp

Issue 2716853002: (WIP) Worker: Merge ParentFrameTaskRunners into TaskRunnerHelper
Patch Set: WIP Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "core/workers/ParentFrameTaskRunners.h"
6
7 #include "core/dom/Document.h"
8 #include "core/frame/LocalFrame.h"
9 #include "public/platform/Platform.h"
10 #include "wtf/Assertions.h"
11 #include "wtf/ThreadingPrimitives.h"
12
13 namespace blink {
14
15 ParentFrameTaskRunners::ParentFrameTaskRunners(LocalFrame* frame)
16 : ContextLifecycleObserver(frame ? frame->document() : nullptr) {
17 if (frame && frame->document())
18 DCHECK(frame->document()->isContextThread());
19
20 // For now we only support very limited task types.
21 for (auto type : {TaskType::UnspecedTimer, TaskType::UnspecedLoading,
22 TaskType::Networking, TaskType::PostedMessage,
23 TaskType::CanvasBlobSerialization, TaskType::Unthrottled}) {
24 m_taskRunners.insert(type, TaskRunnerHelper::get(type, frame));
25 }
26 }
27
28 RefPtr<WebTaskRunner> ParentFrameTaskRunners::get(TaskType type) {
29 MutexLocker lock(m_taskRunnersMutex);
30 return m_taskRunners.at(type);
31 }
32
33 DEFINE_TRACE(ParentFrameTaskRunners) {
34 ContextLifecycleObserver::trace(visitor);
35 }
36
37 void ParentFrameTaskRunners::contextDestroyed(ExecutionContext*) {
38 MutexLocker lock(m_taskRunnersMutex);
39 for (auto& entry : m_taskRunners)
40 entry.value = Platform::current()->currentThread()->getWebTaskRunner();
41 }
42
43 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698