michael@0: /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "Principal.h" michael@0: michael@0: #include "jsapi.h" michael@0: michael@0: BEGIN_WORKERS_NAMESPACE michael@0: michael@0: JSPrincipals* michael@0: GetWorkerPrincipal() michael@0: { michael@0: static Atomic sInitialized(false); michael@0: static JSPrincipals sPrincipal; michael@0: michael@0: bool isInitialized = sInitialized.exchange(true); michael@0: if (!isInitialized) { michael@0: sPrincipal.refcount = 1; michael@0: #ifdef DEBUG michael@0: sPrincipal.debugToken = kJSPrincipalsDebugToken; michael@0: #endif michael@0: } michael@0: return &sPrincipal; michael@0: } michael@0: michael@0: END_WORKERS_NAMESPACE