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

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

Issue 2236833002: Pass per-frame task runners to Workers (when possible) [2nd try] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixing hash traits Created 4 years, 4 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/TaskRunnerHelper.h"
10 #include "core/frame/LocalFrameLifecycleObserver.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 : public GarbageCollectedFinalize d<ParentFrameTaskRunners>, public LocalFrameLifecycleObserver {
30 USING_GARBAGE_COLLECTED_MIXIN(ParentFrameTaskRunners);
31 WTF_MAKE_NONCOPYABLE(ParentFrameTaskRunners);
32
33 public:
34 // LocalFrame could be nullptr if the worker is not associated with a
35 // particular local frame.
36 explicit ParentFrameTaskRunners(LocalFrame*);
37
38 // Might return nullptr for unsupported task types.
39 WebTaskRunner* get(TaskType);
40
41 DECLARE_VIRTUAL_TRACE();
42
43 private:
44 using TaskRunnerHashMap = HashMap<TaskType, WebTaskRunner*, WTF::IntHash<Tas kType>, TaskTypeTraits>;
45
46 void contextDestroyed() override;
47
48 Mutex m_taskRunnersMutex;
49 TaskRunnerHashMap m_taskRunners;
50 };
51
52 } // namespace blink
53
54 #endif // ParentFrameTaskRunners_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698