michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 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: /* describes principals by their orginating uris*/ michael@0: michael@0: #ifndef nsJSPrincipals_h__ michael@0: #define nsJSPrincipals_h__ michael@0: #include "jsapi.h" michael@0: #include "nsIPrincipal.h" michael@0: michael@0: class nsCString; michael@0: michael@0: struct nsJSPrincipals : nsIPrincipal, JSPrincipals michael@0: { michael@0: static bool Subsume(JSPrincipals *jsprin, JSPrincipals *other); michael@0: static void Destroy(JSPrincipals *jsprin); michael@0: michael@0: /* michael@0: * Get a weak reference to nsIPrincipal associated with the given JS michael@0: * principal. michael@0: */ michael@0: static nsJSPrincipals* get(JSPrincipals *principals) { michael@0: nsJSPrincipals *self = static_cast(principals); michael@0: MOZ_ASSERT_IF(self, self->debugToken == DEBUG_TOKEN); michael@0: return self; michael@0: } michael@0: michael@0: static nsJSPrincipals* get(nsIPrincipal *principal) { michael@0: nsJSPrincipals *self = static_cast(principal); michael@0: MOZ_ASSERT_IF(self, self->debugToken == DEBUG_TOKEN); michael@0: return self; michael@0: } michael@0: michael@0: nsJSPrincipals() { michael@0: refcount = 0; michael@0: setDebugToken(DEBUG_TOKEN); michael@0: } michael@0: michael@0: virtual ~nsJSPrincipals() { michael@0: setDebugToken(0); michael@0: } michael@0: michael@0: /** michael@0: * Return a string that can be used as JS script filename in error reports. michael@0: */ michael@0: virtual void GetScriptLocation(nsACString &aStr) = 0; michael@0: michael@0: #ifdef DEBUG michael@0: virtual void dumpImpl() = 0; michael@0: #endif michael@0: michael@0: static const uint32_t DEBUG_TOKEN = 0x0bf41760; michael@0: }; michael@0: michael@0: #endif /* nsJSPrincipals_h__ */