1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/xpconnect/src/BackstagePass.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,60 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef BackstagePass_h__ 1.11 +#define BackstagePass_h__ 1.12 + 1.13 +#include "nsISupports.h" 1.14 +#include "nsWeakReference.h" 1.15 +#include "nsIGlobalObject.h" 1.16 +#include "nsIScriptObjectPrincipal.h" 1.17 +#include "nsIXPCScriptable.h" 1.18 + 1.19 +#include "js/HeapAPI.h" 1.20 + 1.21 +class BackstagePass : public nsIGlobalObject, 1.22 + public nsIScriptObjectPrincipal, 1.23 + public nsIXPCScriptable, 1.24 + public nsIClassInfo, 1.25 + public nsSupportsWeakReference 1.26 +{ 1.27 +public: 1.28 + NS_DECL_ISUPPORTS 1.29 + NS_DECL_NSIXPCSCRIPTABLE 1.30 + NS_DECL_NSICLASSINFO 1.31 + 1.32 + virtual nsIPrincipal* GetPrincipal() { 1.33 + return mPrincipal; 1.34 + } 1.35 + 1.36 + virtual JSObject* GetGlobalJSObject() { 1.37 + return mGlobal; 1.38 + } 1.39 + 1.40 + virtual void ForgetGlobalObject() { 1.41 + mGlobal = nullptr; 1.42 + } 1.43 + 1.44 + virtual void SetGlobalObject(JSObject* global) { 1.45 + mGlobal = global; 1.46 + } 1.47 + 1.48 + BackstagePass(nsIPrincipal *prin) : 1.49 + mPrincipal(prin) 1.50 + { 1.51 + } 1.52 + 1.53 + virtual ~BackstagePass() { } 1.54 + 1.55 +private: 1.56 + nsCOMPtr<nsIPrincipal> mPrincipal; 1.57 + JS::TenuredHeap<JSObject*> mGlobal; 1.58 +}; 1.59 + 1.60 +nsresult 1.61 +NS_NewBackstagePass(BackstagePass** ret); 1.62 + 1.63 +#endif // BackstagePass_h__