зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1315446 Avoid crashing if GetCurrentThreadJSContext() or GetCurrentThreadWorkerGlobal() are called after worker shutdown. r=baku
This commit is contained in:
Родитель
352d267cbb
Коммит
e5bccaf01d
|
@ -1470,13 +1470,25 @@ IsCurrentThreadRunningChromeWorker()
|
|||
JSContext*
|
||||
GetCurrentThreadJSContext()
|
||||
{
|
||||
return GetCurrentThreadWorkerPrivate()->GetJSContext();
|
||||
WorkerPrivate* wp = GetCurrentThreadWorkerPrivate();
|
||||
if (!wp) {
|
||||
return nullptr;
|
||||
}
|
||||
return wp->GetJSContext();
|
||||
}
|
||||
|
||||
JSObject*
|
||||
GetCurrentThreadWorkerGlobal()
|
||||
{
|
||||
return GetCurrentThreadWorkerPrivate()->GlobalScope()->GetGlobalJSObject();
|
||||
WorkerPrivate* wp = GetCurrentThreadWorkerPrivate();
|
||||
if (!wp) {
|
||||
return nullptr;
|
||||
}
|
||||
WorkerGlobalScope* scope = wp->GlobalScope();
|
||||
if (!scope) {
|
||||
return nullptr;
|
||||
}
|
||||
return scope->GetGlobalJSObject();
|
||||
}
|
||||
|
||||
END_WORKERS_NAMESPACE
|
||||
|
|
Загрузка…
Ссылка в новой задаче