1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 
7 #include "Principal.h"
8 
9 #include "JSSettings.h"
10 #include "jsapi.h"
11 #include "mozilla/Assertions.h"
12 #include "mozilla/dom/StructuredCloneTags.h"
13 #include "mozilla/dom/workerinternals/JSSettings.h"
14 
15 namespace mozilla {
16 namespace dom {
17 
WorkerPrincipal(bool aIsSystemOrAddonPrincipal)18 WorkerPrincipal::WorkerPrincipal(bool aIsSystemOrAddonPrincipal)
19     : JSPrincipals(), mIsSystemOrAddonPrincipal(aIsSystemOrAddonPrincipal) {
20   setDebugToken(workerinternals::kJSPrincipalsDebugToken);
21 }
22 
23 WorkerPrincipal::~WorkerPrincipal() = default;
24 
write(JSContext * aCx,JSStructuredCloneWriter * aWriter)25 bool WorkerPrincipal::write(JSContext* aCx, JSStructuredCloneWriter* aWriter) {
26   return JS_WriteUint32Pair(aWriter, SCTAG_DOM_WORKER_PRINCIPAL, 0);
27 }
28 
isSystemOrAddonPrincipal()29 bool WorkerPrincipal::isSystemOrAddonPrincipal() {
30   return mIsSystemOrAddonPrincipal;
31 }
32 
Destroy(JSPrincipals * aPrincipals)33 void WorkerPrincipal::Destroy(JSPrincipals* aPrincipals) {
34   delete static_cast<WorkerPrincipal*>(aPrincipals);
35 }
36 
37 }  // namespace dom
38 }  // namespace mozilla
39