WebTaskSchedulerMainThread.h (1606B)
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim:expandtab:shiftwidth=2:tabstop=2: 3 */ 4 /* This Source Code Form is subject to the terms of the Mozilla Public 5 * License, v. 2.0. If a copy of the MPL was not distributed with this 6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 7 8 #ifndef mozilla_dom_WebSchedulerMainThread_h 9 #define mozilla_dom_WebSchedulerMainThread_h 10 11 #include "WebTaskScheduler.h" 12 #include "mozilla/dom/AbortFollower.h" 13 #include "nsCycleCollectionParticipant.h" 14 #include "nsThreadUtils.h" 15 16 namespace mozilla::dom { 17 class WebTaskMainThreadRunnable final : public Runnable { 18 public: 19 explicit WebTaskMainThreadRunnable(WebTaskSchedulerMainThread* aScheduler) 20 : Runnable("WebTaskMainThreadRunnable"), mScheduler(aScheduler) {} 21 22 MOZ_CAN_RUN_SCRIPT_BOUNDARY NS_IMETHOD Run() override; 23 24 private: 25 ~WebTaskMainThreadRunnable() = default; 26 WeakPtr<WebTaskSchedulerMainThread> mScheduler; 27 }; 28 29 class WebTaskSchedulerMainThread final : public WebTaskScheduler { 30 public: 31 explicit WebTaskSchedulerMainThread(nsIGlobalObject* aParent) 32 : WebTaskScheduler(aParent) {} 33 34 void IncreaseNumNormalOrHighPriorityQueuesHaveTaskScheduled() override; 35 void DecreaseNumNormalOrHighPriorityQueuesHaveTaskScheduled() override; 36 37 private: 38 nsresult SetTimeoutForDelayedTask(WebTask* aTask, uint64_t aDelay, 39 EventQueuePriority aPriority) override; 40 bool DispatchEventLoopRunnable(EventQueuePriority aPriority) override; 41 42 ~WebTaskSchedulerMainThread() = default; 43 }; 44 } // namespace mozilla::dom 45 #endif