Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 for Workers. | |
| 39 WebTaskRunner* get(TaskType); | |
| 40 | |
| 41 DECLARE_VIRTUAL_TRACE(); | |
| 42 | |
| 43 private: | |
| 44 struct TaskTypeTraits : WTF::GenericHashTraits<TaskType> { | |
|
haraken
2016/08/12 00:55:45
Shall we move this to TaskRunnerHelper.h?
kinuko
2016/08/15 22:56:19
Done.
| |
| 45 static const bool emptyValueIsZero = false; | |
| 46 static TaskType emptyValue() { return static_cast<TaskType>(std::numeric _limits<unsigned>::max()); } | |
| 47 static void constructDeletedValue(TaskType& slot, bool) { slot = static_ cast<TaskType>(-1); } | |
| 48 static bool isDeletedValue(TaskType value) { return value == static_cast <TaskType>(-1); } | |
| 49 }; | |
| 50 using TaskRunnerHash = HashMap<TaskType, WebTaskRunner*, WTF::IntHash<TaskTy pe>, TaskTypeTraits>; | |
| 51 | |
| 52 void contextDestroyed() override; | |
| 53 | |
| 54 Mutex m_taskRunnersMutex; | |
| 55 TaskRunnerHash m_taskRunners; | |
|
haraken
2016/08/12 00:55:45
TaskRunnerHash => TaskRunnerHashMap
kinuko
2016/08/15 22:56:19
Done.
| |
| 56 }; | |
| 57 | |
| 58 } // namespace blink | |
| 59 | |
| 60 #endif // ParentFrameTaskRunners_h | |
| OLD | NEW |