dom/workers/Principal.cpp

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:21f0feb405f4
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/. */
5
6 #include "Principal.h"
7
8 #include "jsapi.h"
9
10 BEGIN_WORKERS_NAMESPACE
11
12 JSPrincipals*
13 GetWorkerPrincipal()
14 {
15 static Atomic<bool> sInitialized(false);
16 static JSPrincipals sPrincipal;
17
18 bool isInitialized = sInitialized.exchange(true);
19 if (!isInitialized) {
20 sPrincipal.refcount = 1;
21 #ifdef DEBUG
22 sPrincipal.debugToken = kJSPrincipalsDebugToken;
23 #endif
24 }
25 return &sPrincipal;
26 }
27
28 END_WORKERS_NAMESPACE

mercurial