CefResolveCallback.g.cs 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. //
  2. // DO NOT MODIFY! THIS IS AUTOGENERATED FILE!
  3. //
  4. namespace Xilium.CefGlue
  5. {
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Diagnostics;
  9. using System.Runtime.InteropServices;
  10. using System.Threading;
  11. using Xilium.CefGlue.Interop;
  12. // Role: HANDLER
  13. public abstract unsafe partial class CefResolveCallback
  14. {
  15. private static Dictionary<IntPtr, CefResolveCallback> _roots = new Dictionary<IntPtr, CefResolveCallback>();
  16. private int _refct;
  17. private cef_resolve_callback_t* _self;
  18. private cef_resolve_callback_t.add_ref_delegate _ds0;
  19. private cef_resolve_callback_t.release_delegate _ds1;
  20. private cef_resolve_callback_t.has_one_ref_delegate _ds2;
  21. private cef_resolve_callback_t.has_at_least_one_ref_delegate _ds3;
  22. private cef_resolve_callback_t.on_resolve_completed_delegate _ds4;
  23. protected CefResolveCallback()
  24. {
  25. _self = cef_resolve_callback_t.Alloc();
  26. _ds0 = new cef_resolve_callback_t.add_ref_delegate(add_ref);
  27. _self->_base._add_ref = Marshal.GetFunctionPointerForDelegate(_ds0);
  28. _ds1 = new cef_resolve_callback_t.release_delegate(release);
  29. _self->_base._release = Marshal.GetFunctionPointerForDelegate(_ds1);
  30. _ds2 = new cef_resolve_callback_t.has_one_ref_delegate(has_one_ref);
  31. _self->_base._has_one_ref = Marshal.GetFunctionPointerForDelegate(_ds2);
  32. _ds3 = new cef_resolve_callback_t.has_at_least_one_ref_delegate(has_at_least_one_ref);
  33. _self->_base._has_at_least_one_ref = Marshal.GetFunctionPointerForDelegate(_ds3);
  34. _ds4 = new cef_resolve_callback_t.on_resolve_completed_delegate(on_resolve_completed);
  35. _self->_on_resolve_completed = Marshal.GetFunctionPointerForDelegate(_ds4);
  36. }
  37. ~CefResolveCallback()
  38. {
  39. Dispose(false);
  40. }
  41. protected virtual void Dispose(bool disposing)
  42. {
  43. if (_self != null)
  44. {
  45. cef_resolve_callback_t.Free(_self);
  46. _self = null;
  47. }
  48. }
  49. private void add_ref(cef_resolve_callback_t* self)
  50. {
  51. if (Interlocked.Increment(ref _refct) == 1)
  52. {
  53. lock (_roots) { _roots.Add((IntPtr)_self, this); }
  54. }
  55. }
  56. private int release(cef_resolve_callback_t* self)
  57. {
  58. if (Interlocked.Decrement(ref _refct) == 0)
  59. {
  60. lock (_roots) { _roots.Remove((IntPtr)_self); }
  61. return 1;
  62. }
  63. return 0;
  64. }
  65. private int has_one_ref(cef_resolve_callback_t* self)
  66. {
  67. return _refct == 1 ? 1 : 0;
  68. }
  69. private int has_at_least_one_ref(cef_resolve_callback_t* self)
  70. {
  71. return _refct != 0 ? 1 : 0;
  72. }
  73. internal cef_resolve_callback_t* ToNative()
  74. {
  75. add_ref(_self);
  76. return _self;
  77. }
  78. [Conditional("DEBUG")]
  79. private void CheckSelf(cef_resolve_callback_t* self)
  80. {
  81. if (_self != self) throw ExceptionBuilder.InvalidSelfReference();
  82. }
  83. }
  84. }