mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 04:41:11 +00:00
Bug 1876138: Check if in main thread before attempting to create PerformanceMark. r=dom-worker-reviewers,asuth
Differential Revision: https://phabricator.services.mozilla.com/D199384
This commit is contained in:
parent
afc13a8606
commit
ec1792d1a2
@ -80,20 +80,25 @@ already_AddRefed<Performance> Performance::CreateForWorker(
|
||||
already_AddRefed<Performance> Performance::Get(JSContext* aCx,
|
||||
nsIGlobalObject* aGlobal) {
|
||||
RefPtr<Performance> performance;
|
||||
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aGlobal);
|
||||
if (window) {
|
||||
performance = window->GetPerformance();
|
||||
} else {
|
||||
const WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
|
||||
if (!workerPrivate) {
|
||||
if (NS_IsMainThread()) {
|
||||
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aGlobal);
|
||||
if (!window) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
WorkerGlobalScope* scope = workerPrivate->GlobalScope();
|
||||
MOZ_ASSERT(scope);
|
||||
performance = scope->GetPerformance();
|
||||
performance = window->GetPerformance();
|
||||
return performance.forget();
|
||||
}
|
||||
|
||||
const WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
|
||||
if (!workerPrivate) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
WorkerGlobalScope* scope = workerPrivate->GlobalScope();
|
||||
MOZ_ASSERT(scope);
|
||||
performance = scope->GetPerformance();
|
||||
|
||||
return performance.forget();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user