private void CheckSelf(cef_response_filter_t *self) { if (_self != self) { throw ExceptionBuilder.InvalidSelfReference(); } }
private CefResponseFilterStatus filter(cef_response_filter_t *self, void *data_in, UIntPtr data_in_size, UIntPtr *data_in_read, void *data_out, UIntPtr data_out_size, UIntPtr *data_out_written) { CheckSelf(self); // TODO: Use some buffers instead of UnmanagedMemoryStream. // TODO: Remove UnmanagedMemoryStream - normal usage is buffer operations. UnmanagedMemoryStream m_in_stream = null; UnmanagedMemoryStream m_out_stream = null; try { if (data_in != null) { m_in_stream = new UnmanagedMemoryStream((byte *)data_in, (long)data_in_size, (long)data_in_size, FileAccess.Read); } m_out_stream = new UnmanagedMemoryStream((byte *)data_out, 0, (long)data_out_size, FileAccess.Write); { long m_inRead; long m_outWritten; var result = Filter(m_in_stream, (long)data_in_size, out m_inRead, m_out_stream, (long)data_out_size, out m_outWritten); * data_in_read = (UIntPtr)m_inRead; * data_out_written = (UIntPtr)m_outWritten; return(result); } } finally { m_out_stream?.Dispose(); m_in_stream?.Dispose(); } }
public CefResponseFilter() { cef_response_filter_t *self = this.NativeInstance; self->init_filter = (void *)Marshal.GetFunctionPointerForDelegate(fnInitFilter); self->filter = (void *)Marshal.GetFunctionPointerForDelegate(fnFilter); }
protected virtual void Dispose(bool disposing) { if (_self != null) { cef_response_filter_t.Free(_self); _self = null; } }
private void add_ref(cef_response_filter_t *self) { lock (SyncRoot) { var result = ++_refct; if (result == 1) { lock (_roots) { _roots.Add((IntPtr)_self, this); } } } }
public CefResponseFilter() { cef_response_filter_t *self = this.NativeInstance; #if NET_LESS_5_0 self->init_filter = (void *)Marshal.GetFunctionPointerForDelegate(fnInitFilter); self->filter = (void *)Marshal.GetFunctionPointerForDelegate(fnFilter); #else self->init_filter = (delegate * unmanaged[Stdcall] < cef_response_filter_t *, int >) & InitFilterImpl; self->filter = (delegate * unmanaged[Stdcall] < cef_response_filter_t *, void *, UIntPtr, UIntPtr *, void *, UIntPtr, UIntPtr *, CefResponseFilterStatus >) & FilterImpl; #endif }
private int release(cef_response_filter_t *self) { lock (SyncRoot) { var result = --_refct; if (result == 0) { lock (_roots) { _roots.Remove((IntPtr)_self); } return(1); } return(0); } }
private CefResponseFilterStatus filter(cef_response_filter_t *self, void *data_in, UIntPtr data_in_size, UIntPtr *data_in_read, void *data_out, UIntPtr data_out_size, UIntPtr *data_out_written) { CheckSelf(self); using (var m_in_stream = new UnmanagedMemoryStream((byte *)data_in, (long)data_in_size, (long)data_in_size, FileAccess.Read)) using (var m_out_stream = new UnmanagedMemoryStream((byte *)data_out, 0, (long)data_out_size, FileAccess.Write)) { long m_inRead; long m_outWritten; var result = Filter(m_in_stream, (long)data_in_size, out m_inRead, m_out_stream, (long)data_out_size, out m_outWritten); * data_in_read = (UIntPtr)m_inRead; * data_out_written = (UIntPtr)m_outWritten; return(result); } }
protected CefResponseFilter() { _self = cef_response_filter_t.Alloc(); _ds0 = new cef_response_filter_t.add_ref_delegate(add_ref); _self->_base._add_ref = Marshal.GetFunctionPointerForDelegate(_ds0); _ds1 = new cef_response_filter_t.release_delegate(release); _self->_base._release = Marshal.GetFunctionPointerForDelegate(_ds1); _ds2 = new cef_response_filter_t.has_one_ref_delegate(has_one_ref); _self->_base._has_one_ref = Marshal.GetFunctionPointerForDelegate(_ds2); _ds3 = new cef_response_filter_t.init_filter_delegate(init_filter); _self->_init_filter = Marshal.GetFunctionPointerForDelegate(_ds3); _ds4 = new cef_response_filter_t.filter_delegate(filter); _self->_filter = Marshal.GetFunctionPointerForDelegate(_ds4); }
internal static void Free(cef_response_filter_t *ptr) { Marshal.FreeHGlobal((IntPtr)ptr); }
private int init_filter(cef_response_filter_t *self) { CheckSelf(self); return(InitFilter() ? 1 : 0); }
private int has_one_ref(cef_response_filter_t *self) { lock (SyncRoot) { return(_refct == 1 ? 1 : 0); } }
private int has_at_least_one_ref(cef_response_filter_t *self) { lock (SyncRoot) { return(_refct != 0 ? 1 : 0); } }
public CefResponseFilter(cef_response_filter_t *instance) : base((cef_base_ref_counted_t *)instance) { }