1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/xpconnect/public/SandboxPrivate.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,56 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +/* vim: set ts=8 sts=4 et sw=4 tw=99: */ 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 __SANDBOXPRIVATE_H__ 1.11 +#define __SANDBOXPRIVATE_H__ 1.12 + 1.13 +#include "nsIGlobalObject.h" 1.14 +#include "nsIScriptObjectPrincipal.h" 1.15 +#include "nsIPrincipal.h" 1.16 +#include "nsWeakReference.h" 1.17 +#include "nsWrapperCache.h" 1.18 + 1.19 +#include "js/RootingAPI.h" 1.20 + 1.21 +// This interface is public only because it is used in jsd. 1.22 +// Once jsd is gone this file should be moved back to xpconnect/src. 1.23 + 1.24 +class SandboxPrivate : public nsIGlobalObject, 1.25 + public nsIScriptObjectPrincipal, 1.26 + public nsSupportsWeakReference, 1.27 + public nsWrapperCache 1.28 +{ 1.29 +public: 1.30 + SandboxPrivate(nsIPrincipal *principal, JSObject *global) 1.31 + : mPrincipal(principal) 1.32 + { 1.33 + SetWrapper(global); 1.34 + } 1.35 + virtual ~SandboxPrivate() { } 1.36 + 1.37 + NS_DECL_CYCLE_COLLECTING_ISUPPORTS 1.38 + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(SandboxPrivate, 1.39 + nsIGlobalObject) 1.40 + 1.41 + nsIPrincipal *GetPrincipal() 1.42 + { 1.43 + return mPrincipal; 1.44 + } 1.45 + 1.46 + JSObject *GetGlobalJSObject() 1.47 + { 1.48 + return GetWrapper(); 1.49 + } 1.50 + 1.51 + void ForgetGlobalObject() 1.52 + { 1.53 + ClearWrapper(); 1.54 + } 1.55 +private: 1.56 + nsCOMPtr<nsIPrincipal> mPrincipal; 1.57 +}; 1.58 + 1.59 +#endif // __SANDBOXPRIVATE_H__