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

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

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 #ifndef ParentFrameTaskRunners_h
6 #define ParentFrameTaskRunners_h
7
8 #include "core/CoreExport.h"
9 #include "core/dom/ContextLifecycleObserver.h"
10 #include "core/dom/TaskRunnerHelper.h"
11 #include "platform/heap/Handle.h"
12 #include "wtf/Allocator.h"
13 #include "wtf/Noncopyable.h"
14 #include "wtf/PtrUtil.h"
15 #include <memory>
16
17 namespace blink {
18
19 class LocalFrame;
20 class WebTaskRunner;
21
22 // Represents a set of task runners of the parent (or associated) document's
23 // frame. This could be accessed from worker thread(s) and must be initialized
24 // on the parent context thread (i.e. MainThread) on construction time, rather
25 // than being done lazily.
26 //
27 // This observes LocalFrame lifecycle only for in-process worker cases (i.e.
28 // only when a non-null LocalFrame is given).
29 class CORE_EXPORT ParentFrameTaskRunners final
30 : public GarbageCollectedFinalized<ParentFrameTaskRunners>,
31 public ContextLifecycleObserver {
32 USING_GARBAGE_COLLECTED_MIXIN(ParentFrameTaskRunners);
33 WTF_MAKE_NONCOPYABLE(ParentFrameTaskRunners);
34
35 public:
36 static ParentFrameTaskRunners* create(LocalFrame* frame) {
37 return new ParentFrameTaskRunners(frame);
38 }
39
40 // Might return nullptr for unsupported task types.
41 RefPtr<WebTaskRunner> get(TaskType);
42
43 DECLARE_VIRTUAL_TRACE();
44
45 private:
46 using TaskRunnerHashMap = HashMap<TaskType,
47 RefPtr<WebTaskRunner>,
48 WTF::IntHash<TaskType>,
49 TaskTypeTraits>;
50
51 // LocalFrame could be nullptr if the worker is not associated with a
52 // particular local frame.
53 explicit ParentFrameTaskRunners(LocalFrame*);
54
55 void contextDestroyed(ExecutionContext*) override;
56
57 Mutex m_taskRunnersMutex;
58 TaskRunnerHashMap m_taskRunners;
59 };
60
61 } // namespace blink
62
63 #endif // ParentFrameTaskRunners_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698