1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:expandtab:shiftwidth=2:tabstop=2:
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/. */
8 #ifndef mozilla_dom_WebTaskSchedulerWorker_h
9 #define mozilla_dom_WebTaskSchedulerWorker_h
11 #include "WebTaskScheduler.h"
13 #include "mozilla/LinkedList.h"
14 #include "mozilla/dom/WorkerRunnable.h"
15 #include "mozilla/dom/WorkerPrivate.h"
16 #include "mozilla/dom/WebTaskSchedulingBinding.h"
18 namespace mozilla::dom
{
20 class WebTaskWorkerRunnable
: public WorkerSameThreadRunnable
{
22 WebTaskWorkerRunnable(WorkerPrivate
* aWorkerPrivate
,
23 WebTaskSchedulerWorker
* aSchedulerWorker
);
25 MOZ_CAN_RUN_SCRIPT_BOUNDARY
26 bool WorkerRun(JSContext
* aCx
, WorkerPrivate
* aWorkerPrivate
) override
;
29 ~WebTaskWorkerRunnable() = default;
30 WeakPtr
<WebTaskSchedulerWorker
> mSchedulerWorker
;
33 class WebTaskSchedulerWorker final
: public WebTaskScheduler
{
35 explicit WebTaskSchedulerWorker(WorkerPrivate
* aWorkerPrivate
);
38 ~WebTaskSchedulerWorker() = default;
40 nsresult
SetTimeoutForDelayedTask(WebTask
* aTask
, uint64_t aDelay
) override
;
41 bool DispatchEventLoopRunnable() override
;
43 CheckedUnsafePtr
<WorkerPrivate
> mWorkerPrivate
;
45 } // namespace mozilla::dom