mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 06:43:32 +00:00
Bug 1874080 - Nullify WebTaskSchedulerWorker::mWorkerPrivate while Disconnect(). r=smaug, a=RyanVM
Differential Revision: https://phabricator.services.mozilla.com/D198569
This commit is contained in:
parent
d768626a47
commit
666a1b73db
@ -113,7 +113,7 @@ class WebTaskScheduler : public nsWrapperCache, public SupportsWeakPtr {
|
||||
|
||||
WebTask* GetNextTask() const;
|
||||
|
||||
void Disconnect();
|
||||
virtual void Disconnect();
|
||||
|
||||
void RunTaskSignalPriorityChange(TaskSignal* aTaskSignal);
|
||||
|
||||
|
@ -36,6 +36,9 @@ bool WebTaskWorkerRunnable::WorkerRun(JSContext* aCx,
|
||||
|
||||
nsresult WebTaskSchedulerWorker::SetTimeoutForDelayedTask(WebTask* aTask,
|
||||
uint64_t aDelay) {
|
||||
if (!mWorkerPrivate) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
JSContext* cx = nsContentUtils::GetCurrentJSContext();
|
||||
if (!cx) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
@ -52,8 +55,18 @@ nsresult WebTaskSchedulerWorker::SetTimeoutForDelayedTask(WebTask* aTask,
|
||||
}
|
||||
|
||||
bool WebTaskSchedulerWorker::DispatchEventLoopRunnable() {
|
||||
if (!mWorkerPrivate) {
|
||||
return false;
|
||||
}
|
||||
RefPtr<WebTaskWorkerRunnable> runnable =
|
||||
new WebTaskWorkerRunnable(mWorkerPrivate, this);
|
||||
return runnable->Dispatch();
|
||||
}
|
||||
|
||||
void WebTaskSchedulerWorker::Disconnect() {
|
||||
if (mWorkerPrivate) {
|
||||
mWorkerPrivate = nullptr;
|
||||
}
|
||||
WebTaskScheduler::Disconnect();
|
||||
}
|
||||
} // namespace mozilla::dom
|
||||
|
@ -34,6 +34,8 @@ class WebTaskSchedulerWorker final : public WebTaskScheduler {
|
||||
public:
|
||||
explicit WebTaskSchedulerWorker(WorkerPrivate* aWorkerPrivate);
|
||||
|
||||
void Disconnect() override;
|
||||
|
||||
private:
|
||||
~WebTaskSchedulerWorker() = default;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user