Bumping manifests a=b2g-bump
[gecko.git] / caps / nsJSPrincipals.h
blob5b63574cf43627824ddd4a1ce48fd3570b0fca87
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
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 /* describes principals by their orginating uris*/
7 #ifndef nsJSPrincipals_h__
8 #define nsJSPrincipals_h__
9 #include "jsapi.h"
10 #include "nsIPrincipal.h"
12 class nsCString;
14 struct nsJSPrincipals : nsIPrincipal, JSPrincipals
16 static bool Subsume(JSPrincipals *jsprin, JSPrincipals *other);
17 static void Destroy(JSPrincipals *jsprin);
20 * Get a weak reference to nsIPrincipal associated with the given JS
21 * principal.
23 static nsJSPrincipals* get(JSPrincipals *principals) {
24 nsJSPrincipals *self = static_cast<nsJSPrincipals *>(principals);
25 MOZ_ASSERT_IF(self, self->debugToken == DEBUG_TOKEN);
26 return self;
29 static nsJSPrincipals* get(nsIPrincipal *principal) {
30 nsJSPrincipals *self = static_cast<nsJSPrincipals *>(principal);
31 MOZ_ASSERT_IF(self, self->debugToken == DEBUG_TOKEN);
32 return self;
35 nsJSPrincipals() {
36 refcount = 0;
37 setDebugToken(DEBUG_TOKEN);
40 virtual ~nsJSPrincipals() {
41 setDebugToken(0);
44 /**
45 * Return a string that can be used as JS script filename in error reports.
47 virtual void GetScriptLocation(nsACString &aStr) = 0;
49 #ifdef DEBUG
50 virtual void dumpImpl() = 0;
51 #endif
53 static const uint32_t DEBUG_TOKEN = 0x0bf41760;
56 #endif /* nsJSPrincipals_h__ */