1 /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
9 #include "mozilla/Assertions.h"
11 BEGIN_WORKERS_NAMESPACE
16 static JSPrincipals sPrincipal
;
19 * To make sure the the principals refcount is initialized to one, atomically
20 * increment it on every pass though this function. If we discover this wasn't
21 * the first time, decrement it again. This avoids the need for
24 int32_t prevRefcount
= sPrincipal
.refcount
++;
25 if (prevRefcount
> 0) {
26 --sPrincipal
.refcount
;
29 sPrincipal
.debugToken
= kJSPrincipalsDebugToken
;
37 DestroyWorkerPrincipals(JSPrincipals
* aPrincipals
)
39 MOZ_ASSERT_UNREACHABLE("Worker principals refcount should never fall below one");