|
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*/ |
|
6 |
|
7 #ifndef nsJSPrincipals_h__ |
|
8 #define nsJSPrincipals_h__ |
|
9 #include "jsapi.h" |
|
10 #include "nsIPrincipal.h" |
|
11 |
|
12 class nsCString; |
|
13 |
|
14 struct nsJSPrincipals : nsIPrincipal, JSPrincipals |
|
15 { |
|
16 static bool Subsume(JSPrincipals *jsprin, JSPrincipals *other); |
|
17 static void Destroy(JSPrincipals *jsprin); |
|
18 |
|
19 /* |
|
20 * Get a weak reference to nsIPrincipal associated with the given JS |
|
21 * principal. |
|
22 */ |
|
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; |
|
27 } |
|
28 |
|
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; |
|
33 } |
|
34 |
|
35 nsJSPrincipals() { |
|
36 refcount = 0; |
|
37 setDebugToken(DEBUG_TOKEN); |
|
38 } |
|
39 |
|
40 virtual ~nsJSPrincipals() { |
|
41 setDebugToken(0); |
|
42 } |
|
43 |
|
44 /** |
|
45 * Return a string that can be used as JS script filename in error reports. |
|
46 */ |
|
47 virtual void GetScriptLocation(nsACString &aStr) = 0; |
|
48 |
|
49 #ifdef DEBUG |
|
50 virtual void dumpImpl() = 0; |
|
51 #endif |
|
52 |
|
53 static const uint32_t DEBUG_TOKEN = 0x0bf41760; |
|
54 }; |
|
55 |
|
56 #endif /* nsJSPrincipals_h__ */ |