mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-21 01:05:45 +00:00
cdd2029b79
Unlike WorkletPrincipal, a WorkerPrincipal had been a simple static object shared by all Workers. We never needed to consult it about an individual Worker before. Now we do. So we cut it over from a static object to individual objects for each Worker. We have an off main thread access problem for the Principal however, WorkerPrivate has a method UsesSystemPrincipal that returns a bool that was initialized from the Principal on the main thread. We copy that pattern and add a UsesAddonOrExpandedAddonPrincipal method that will be called by the isSystemOrAddonPrincipal method we must implement so we can inheirt from JSPrincipal. Differential Revision: https://phabricator.services.mozilla.com/D47476 --HG-- extra : moz-landing-system : lando
37 lines
1.1 KiB
C++
37 lines
1.1 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "Principal.h"
|
|
|
|
#include "jsapi.h"
|
|
#include "mozilla/Assertions.h"
|
|
#include "mozilla/dom/StructuredCloneTags.h"
|
|
|
|
namespace mozilla {
|
|
namespace dom {
|
|
|
|
WorkerPrincipal::WorkerPrincipal(bool aIsSystemOrAddonPrincipal)
|
|
: JSPrincipals(), mIsSystemOrAddonPrincipal(aIsSystemOrAddonPrincipal) {
|
|
setDebugToken(workerinternals::kJSPrincipalsDebugToken);
|
|
}
|
|
|
|
WorkerPrincipal::~WorkerPrincipal() = default;
|
|
|
|
bool WorkerPrincipal::write(JSContext* aCx, JSStructuredCloneWriter* aWriter) {
|
|
return JS_WriteUint32Pair(aWriter, SCTAG_DOM_WORKER_PRINCIPAL, 0);
|
|
}
|
|
|
|
bool WorkerPrincipal::isSystemOrAddonPrincipal() {
|
|
return mIsSystemOrAddonPrincipal;
|
|
}
|
|
|
|
void WorkerPrincipal::Destroy(JSPrincipals* aPrincipals) {
|
|
delete static_cast<WorkerPrincipal*>(aPrincipals);
|
|
}
|
|
|
|
} // namespace dom
|
|
} // namespace mozilla
|