bug 1578623 store PrincipalInfo on WorkletImpl for off-main-thread use r=baku

Differential Revision: https://phabricator.services.mozilla.com/D44603

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Karl Tomlinson 2019-09-09 00:41:57 +00:00
Родитель f40d806c0d
Коммит a931bb8408
2 изменённых файлов: 8 добавлений и 1 удалений

Просмотреть файл

@ -38,7 +38,10 @@ WorkletImpl::WorkletImpl(nsPIDOMWindowInner* aWindow, nsIPrincipal* aPrincipal)
: mOriginAttributes(BasePrincipal::Cast(aPrincipal)->OriginAttributesRef()),
mPrincipal(NullPrincipal::CreateWithInheritedAttributes(aPrincipal)),
mWorkletLoadInfo(aWindow),
mTerminated(false) {}
mTerminated(false) {
Unused << NS_WARN_IF(
NS_FAILED(ipc::PrincipalToPrincipalInfo(mPrincipal, &mPrincipalInfo)));
}
WorkletImpl::~WorkletImpl() {
MOZ_ASSERT(!mGlobalScope);

Просмотреть файл

@ -9,6 +9,7 @@
#include "MainThreadUtils.h"
#include "mozilla/OriginAttributes.h"
#include "mozilla/ipc/PBackgroundSharedTypes.h"
class nsPIDOMWindowInner;
class nsIPrincipal;
@ -71,6 +72,7 @@ class WorkletImpl {
const OriginAttributes& OriginAttributesRef() const {
return mOriginAttributes;
}
const ipc::PrincipalInfo& PrincipalInfo() const { return mPrincipalInfo; }
protected:
WorkletImpl(nsPIDOMWindowInner* aWindow, nsIPrincipal* aPrincipal);
@ -79,6 +81,8 @@ class WorkletImpl {
virtual already_AddRefed<dom::WorkletGlobalScope> ConstructGlobalScope() = 0;
const OriginAttributes mOriginAttributes;
// Modified only in constructor.
ipc::PrincipalInfo mPrincipalInfo;
// Accessed on only worklet parent thread.
nsCOMPtr<nsIPrincipal> mPrincipal;