forked from mirrors/gecko-dev
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
1 changed files with 14 additions and 9 deletions
|
|
@ -80,20 +80,25 @@ already_AddRefed<Performance> Performance::CreateForWorker(
|
||||||
already_AddRefed<Performance> Performance::Get(JSContext* aCx,
|
already_AddRefed<Performance> Performance::Get(JSContext* aCx,
|
||||||
nsIGlobalObject* aGlobal) {
|
nsIGlobalObject* aGlobal) {
|
||||||
RefPtr<Performance> performance;
|
RefPtr<Performance> performance;
|
||||||
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aGlobal);
|
if (NS_IsMainThread()) {
|
||||||
if (window) {
|
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aGlobal);
|
||||||
performance = window->GetPerformance();
|
if (!window) {
|
||||||
} else {
|
|
||||||
const WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
|
|
||||||
if (!workerPrivate) {
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
WorkerGlobalScope* scope = workerPrivate->GlobalScope();
|
performance = window->GetPerformance();
|
||||||
MOZ_ASSERT(scope);
|
return performance.forget();
|
||||||
performance = scope->GetPerformance();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
|
||||||
|
if (!workerPrivate) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
WorkerGlobalScope* scope = workerPrivate->GlobalScope();
|
||||||
|
MOZ_ASSERT(scope);
|
||||||
|
performance = scope->GetPerformance();
|
||||||
|
|
||||||
return performance.forget();
|
return performance.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue