123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- //
- // DO NOT MODIFY! THIS IS AUTOGENERATED FILE!
- //
- namespace Xilium.CefGlue
- {
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Runtime.InteropServices;
- using System.Threading;
- using Xilium.CefGlue.Interop;
-
- // Role: HANDLER
- public abstract unsafe partial class CefExtensionHandler
- {
- private static Dictionary<IntPtr, CefExtensionHandler> _roots = new Dictionary<IntPtr, CefExtensionHandler>();
-
- private int _refct;
- private cef_extension_handler_t* _self;
-
- internal static CefExtensionHandler FromNativeOrNull(cef_extension_handler_t* ptr)
- {
- CefExtensionHandler value = null;
- bool found;
- lock (_roots)
- {
- found = _roots.TryGetValue((IntPtr)ptr, out value);
- // as we're getting the ref from the outside, it's our responsibility to decrement it
- value.release(ptr);
- }
- return found ? value : null;
- }
-
- internal static CefExtensionHandler FromNative(cef_extension_handler_t* ptr)
- {
- var value = FromNativeOrNull(ptr);
- if (value == null) throw ExceptionBuilder.ObjectNotFound();
- return value;
- }
-
- private cef_extension_handler_t.add_ref_delegate _ds0;
- private cef_extension_handler_t.release_delegate _ds1;
- private cef_extension_handler_t.has_one_ref_delegate _ds2;
- private cef_extension_handler_t.has_at_least_one_ref_delegate _ds3;
- private cef_extension_handler_t.on_extension_load_failed_delegate _ds4;
- private cef_extension_handler_t.on_extension_loaded_delegate _ds5;
- private cef_extension_handler_t.on_extension_unloaded_delegate _ds6;
- private cef_extension_handler_t.on_before_background_browser_delegate _ds7;
- private cef_extension_handler_t.on_before_browser_delegate _ds8;
- private cef_extension_handler_t.get_active_browser_delegate _ds9;
- private cef_extension_handler_t.can_access_browser_delegate _dsa;
- private cef_extension_handler_t.get_extension_resource_delegate _dsb;
-
- protected CefExtensionHandler()
- {
- _self = cef_extension_handler_t.Alloc();
-
- _ds0 = new cef_extension_handler_t.add_ref_delegate(add_ref);
- _self->_base._add_ref = Marshal.GetFunctionPointerForDelegate(_ds0);
- _ds1 = new cef_extension_handler_t.release_delegate(release);
- _self->_base._release = Marshal.GetFunctionPointerForDelegate(_ds1);
- _ds2 = new cef_extension_handler_t.has_one_ref_delegate(has_one_ref);
- _self->_base._has_one_ref = Marshal.GetFunctionPointerForDelegate(_ds2);
- _ds3 = new cef_extension_handler_t.has_at_least_one_ref_delegate(has_at_least_one_ref);
- _self->_base._has_at_least_one_ref = Marshal.GetFunctionPointerForDelegate(_ds3);
- _ds4 = new cef_extension_handler_t.on_extension_load_failed_delegate(on_extension_load_failed);
- _self->_on_extension_load_failed = Marshal.GetFunctionPointerForDelegate(_ds4);
- _ds5 = new cef_extension_handler_t.on_extension_loaded_delegate(on_extension_loaded);
- _self->_on_extension_loaded = Marshal.GetFunctionPointerForDelegate(_ds5);
- _ds6 = new cef_extension_handler_t.on_extension_unloaded_delegate(on_extension_unloaded);
- _self->_on_extension_unloaded = Marshal.GetFunctionPointerForDelegate(_ds6);
- _ds7 = new cef_extension_handler_t.on_before_background_browser_delegate(on_before_background_browser);
- _self->_on_before_background_browser = Marshal.GetFunctionPointerForDelegate(_ds7);
- _ds8 = new cef_extension_handler_t.on_before_browser_delegate(on_before_browser);
- _self->_on_before_browser = Marshal.GetFunctionPointerForDelegate(_ds8);
- _ds9 = new cef_extension_handler_t.get_active_browser_delegate(get_active_browser);
- _self->_get_active_browser = Marshal.GetFunctionPointerForDelegate(_ds9);
- _dsa = new cef_extension_handler_t.can_access_browser_delegate(can_access_browser);
- _self->_can_access_browser = Marshal.GetFunctionPointerForDelegate(_dsa);
- _dsb = new cef_extension_handler_t.get_extension_resource_delegate(get_extension_resource);
- _self->_get_extension_resource = Marshal.GetFunctionPointerForDelegate(_dsb);
- }
-
- ~CefExtensionHandler()
- {
- Dispose(false);
- }
-
- protected virtual void Dispose(bool disposing)
- {
- if (_self != null)
- {
- cef_extension_handler_t.Free(_self);
- _self = null;
- }
- }
-
- private void add_ref(cef_extension_handler_t* self)
- {
- if (Interlocked.Increment(ref _refct) == 1)
- {
- lock (_roots) { _roots.Add((IntPtr)_self, this); }
- }
- }
-
- private int release(cef_extension_handler_t* self)
- {
- if (Interlocked.Decrement(ref _refct) == 0)
- {
- lock (_roots) { _roots.Remove((IntPtr)_self); }
- return 1;
- }
- return 0;
- }
-
- private int has_one_ref(cef_extension_handler_t* self)
- {
- return _refct == 1 ? 1 : 0;
- }
-
- private int has_at_least_one_ref(cef_extension_handler_t* self)
- {
- return _refct != 0 ? 1 : 0;
- }
-
- internal cef_extension_handler_t* ToNative()
- {
- add_ref(_self);
- return _self;
- }
-
- [Conditional("DEBUG")]
- private void CheckSelf(cef_extension_handler_t* self)
- {
- if (_self != self) throw ExceptionBuilder.InvalidSelfReference();
- }
-
- }
- }
|