CefResponseFilter.g.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 CefResponseFilter
  14. {
  15. private static Dictionary<IntPtr, CefResponseFilter> _roots = new Dictionary<IntPtr, CefResponseFilter>();
  16. private int _refct;
  17. private cef_response_filter_t* _self;
  18. private cef_response_filter_t.add_ref_delegate _ds0;
  19. private cef_response_filter_t.release_delegate _ds1;
  20. private cef_response_filter_t.has_one_ref_delegate _ds2;
  21. private cef_response_filter_t.has_at_least_one_ref_delegate _ds3;
  22. private cef_response_filter_t.init_filter_delegate _ds4;
  23. private cef_response_filter_t.filter_delegate _ds5;
  24. protected CefResponseFilter()
  25. {
  26. _self = cef_response_filter_t.Alloc();
  27. _ds0 = new cef_response_filter_t.add_ref_delegate(add_ref);
  28. _self->_base._add_ref = Marshal.GetFunctionPointerForDelegate(_ds0);
  29. _ds1 = new cef_response_filter_t.release_delegate(release);
  30. _self->_base._release = Marshal.GetFunctionPointerForDelegate(_ds1);
  31. _ds2 = new cef_response_filter_t.has_one_ref_delegate(has_one_ref);
  32. _self->_base._has_one_ref = Marshal.GetFunctionPointerForDelegate(_ds2);
  33. _ds3 = new cef_response_filter_t.has_at_least_one_ref_delegate(has_at_least_one_ref);
  34. _self->_base._has_at_least_one_ref = Marshal.GetFunctionPointerForDelegate(_ds3);
  35. _ds4 = new cef_response_filter_t.init_filter_delegate(init_filter);
  36. _self->_init_filter = Marshal.GetFunctionPointerForDelegate(_ds4);
  37. _ds5 = new cef_response_filter_t.filter_delegate(filter);
  38. _self->_filter = Marshal.GetFunctionPointerForDelegate(_ds5);
  39. }
  40. ~CefResponseFilter()
  41. {
  42. Dispose(false);
  43. }
  44. private void Dispose()
  45. {
  46. Dispose(true);
  47. GC.SuppressFinalize(this);
  48. }
  49. protected virtual void Dispose(bool disposing)
  50. {
  51. if (_self != null)
  52. {
  53. cef_response_filter_t.Free(_self);
  54. _self = null;
  55. }
  56. }
  57. private void add_ref(cef_response_filter_t* self)
  58. {
  59. if (Interlocked.Increment(ref _refct) == 1)
  60. {
  61. lock (_roots) { _roots.Add((IntPtr)_self, this); }
  62. }
  63. }
  64. private int release(cef_response_filter_t* self)
  65. {
  66. if (Interlocked.Decrement(ref _refct) == 0)
  67. {
  68. lock (_roots) { _roots.Remove((IntPtr)_self); }
  69. Dispose();
  70. return 1;
  71. }
  72. return 0;
  73. }
  74. private int has_one_ref(cef_response_filter_t* self)
  75. {
  76. return _refct == 1 ? 1 : 0;
  77. }
  78. private int has_at_least_one_ref(cef_response_filter_t* self)
  79. {
  80. return _refct != 0 ? 1 : 0;
  81. }
  82. internal cef_response_filter_t* ToNative()
  83. {
  84. add_ref(_self);
  85. return _self;
  86. }
  87. [Conditional("DEBUG")]
  88. private void CheckSelf(cef_response_filter_t* self)
  89. {
  90. if (_self != self) throw ExceptionBuilder.InvalidSelfReference();
  91. }
  92. }
  93. }