1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/caps/include/nsJSPrincipals.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,56 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 +/* describes principals by their orginating uris*/ 1.9 + 1.10 +#ifndef nsJSPrincipals_h__ 1.11 +#define nsJSPrincipals_h__ 1.12 +#include "jsapi.h" 1.13 +#include "nsIPrincipal.h" 1.14 + 1.15 +class nsCString; 1.16 + 1.17 +struct nsJSPrincipals : nsIPrincipal, JSPrincipals 1.18 +{ 1.19 + static bool Subsume(JSPrincipals *jsprin, JSPrincipals *other); 1.20 + static void Destroy(JSPrincipals *jsprin); 1.21 + 1.22 + /* 1.23 + * Get a weak reference to nsIPrincipal associated with the given JS 1.24 + * principal. 1.25 + */ 1.26 + static nsJSPrincipals* get(JSPrincipals *principals) { 1.27 + nsJSPrincipals *self = static_cast<nsJSPrincipals *>(principals); 1.28 + MOZ_ASSERT_IF(self, self->debugToken == DEBUG_TOKEN); 1.29 + return self; 1.30 + } 1.31 + 1.32 + static nsJSPrincipals* get(nsIPrincipal *principal) { 1.33 + nsJSPrincipals *self = static_cast<nsJSPrincipals *>(principal); 1.34 + MOZ_ASSERT_IF(self, self->debugToken == DEBUG_TOKEN); 1.35 + return self; 1.36 + } 1.37 + 1.38 + nsJSPrincipals() { 1.39 + refcount = 0; 1.40 + setDebugToken(DEBUG_TOKEN); 1.41 + } 1.42 + 1.43 + virtual ~nsJSPrincipals() { 1.44 + setDebugToken(0); 1.45 + } 1.46 + 1.47 + /** 1.48 + * Return a string that can be used as JS script filename in error reports. 1.49 + */ 1.50 + virtual void GetScriptLocation(nsACString &aStr) = 0; 1.51 + 1.52 +#ifdef DEBUG 1.53 + virtual void dumpImpl() = 0; 1.54 +#endif 1.55 + 1.56 + static const uint32_t DEBUG_TOKEN = 0x0bf41760; 1.57 +}; 1.58 + 1.59 +#endif /* nsJSPrincipals_h__ */