Example #1
0
        private static bool MemoryCallbackThunk(IntPtr callbackState, JavaScriptMemoryAllocationEventType allocationEvent, UIntPtr allocationSize)
        {
            GCHandle          handle  = GCHandle.FromIntPtr(callbackState);
            JavaScriptRuntime runtime = handle.Target as JavaScriptRuntime;

            if (runtime == null)
            {
                Debug.Assert(false, "Runtime has been freed.");
                return(false);
            }

            var args = new JavaScriptMemoryAllocationEventArgs(allocationSize, allocationEvent);

            runtime.OnMemoryChanging(args);

            if (args.IsCancelable && args.Cancel)
            {
                return(false);
            }

            return(true);
        }
Example #2
0
        private static bool MemoryCallbackThunk(IntPtr callbackState, JavaScriptMemoryAllocationEventType allocationEvent, UIntPtr allocationSize)
        {
            GCHandle handle = GCHandle.FromIntPtr(callbackState);
            JavaScriptRuntime runtime = handle.Target as JavaScriptRuntime;
            if (runtime == null)
            {
                Debug.Assert(false, "Runtime has been freed.");
                return false;
            }

            var args = new JavaScriptMemoryAllocationEventArgs(allocationSize, allocationEvent);
            runtime.OnMemoryChanging(args);

            if (args.IsCancelable && args.Cancel)
                return false;

            return true;
        }
 internal JavaScriptMemoryAllocationEventArgs(UIntPtr amount, JavaScriptMemoryAllocationEventType type)
 {
     Amount = amount;
     Type   = type;
 }
 internal JavaScriptMemoryAllocationEventArgs(UIntPtr amount, JavaScriptMemoryAllocationEventType type)
 {
     Amount = amount;
     Type = type;
 }