CrossSite.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. #pragma once
  6. class DOMFastPathInfo;
  7. namespace Js
  8. {
  9. class CrossSite
  10. {
  11. friend class ExternalType;
  12. friend class DOMFastPathInfo;
  13. public:
  14. static bool IsThunk(JavascriptMethod thunk);
  15. static BOOL NeedMarshalVar(Var instance, ScriptContext * requestContext);
  16. static Var DefaultThunk(RecyclableObject* function, CallInfo callInfo, ...);
  17. static Var ProfileThunk(RecyclableObject* function, CallInfo callInfo, ...);
  18. static Var CrossSiteProxyCallTrap(RecyclableObject* function, CallInfo callInfo, ...);
  19. static Var MarshalVar(ScriptContext* scriptContext, Var value, bool fRequestWrapper = false);
  20. static void MarshalDynamicObjectAndPrototype(ScriptContext * scriptContext, DynamicObject * object);
  21. static void ForceCrossSiteThunkOnPrototypeChain(RecyclableObject* object);
  22. // If we know the type of the object, use this to do a virtual table check instead of a virtual call
  23. template <typename T>
  24. static BOOL IsCrossSiteObjectTyped(T * obj)
  25. {
  26. BOOL ret = VirtualTableInfo<CrossSiteObject<T>>::HasVirtualTable(obj);
  27. Assert(ret || VirtualTableInfo<T>::HasVirtualTable(obj));
  28. Assert(ret == obj->IsCrossSiteObject());
  29. return ret;
  30. }
  31. #if ENABLE_TTD
  32. static void MarshalCrossSite_TTDInflate(DynamicObject* obj);
  33. #endif
  34. private:
  35. static Var MarshalVarInner(ScriptContext* scriptContext, __in Js::RecyclableObject* object, bool fRequestWrapper);
  36. static Var CommonThunk(RecyclableObject * function, JavascriptMethod entryPoint, Arguments args);
  37. static void MarshalDynamicObject(ScriptContext * scriptContext, DynamicObject * object);
  38. static void MarshalPrototypeChain(ScriptContext * scriptContext, DynamicObject * object);
  39. static Var MarshalFrameDisplay(ScriptContext* scriptContext, FrameDisplay *display);
  40. static bool DoRequestWrapper(Js::RecyclableObject* object, bool fRequestWrapper);
  41. };
  42. };