CefResourceRequestHandler.g.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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 CefResourceRequestHandler
  14. {
  15. private static Dictionary<IntPtr, CefResourceRequestHandler> _roots = new Dictionary<IntPtr, CefResourceRequestHandler>();
  16. private int _refct;
  17. private cef_resource_request_handler_t* _self;
  18. private cef_resource_request_handler_t.add_ref_delegate _ds0;
  19. private cef_resource_request_handler_t.release_delegate _ds1;
  20. private cef_resource_request_handler_t.has_one_ref_delegate _ds2;
  21. private cef_resource_request_handler_t.has_at_least_one_ref_delegate _ds3;
  22. private cef_resource_request_handler_t.get_cookie_access_filter_delegate _ds4;
  23. private cef_resource_request_handler_t.on_before_resource_load_delegate _ds5;
  24. private cef_resource_request_handler_t.get_resource_handler_delegate _ds6;
  25. private cef_resource_request_handler_t.on_resource_redirect_delegate _ds7;
  26. private cef_resource_request_handler_t.on_resource_response_delegate _ds8;
  27. private cef_resource_request_handler_t.get_resource_response_filter_delegate _ds9;
  28. private cef_resource_request_handler_t.on_resource_load_complete_delegate _dsa;
  29. private cef_resource_request_handler_t.on_protocol_execution_delegate _dsb;
  30. protected CefResourceRequestHandler()
  31. {
  32. _self = cef_resource_request_handler_t.Alloc();
  33. _ds0 = new cef_resource_request_handler_t.add_ref_delegate(add_ref);
  34. _self->_base._add_ref = Marshal.GetFunctionPointerForDelegate(_ds0);
  35. _ds1 = new cef_resource_request_handler_t.release_delegate(release);
  36. _self->_base._release = Marshal.GetFunctionPointerForDelegate(_ds1);
  37. _ds2 = new cef_resource_request_handler_t.has_one_ref_delegate(has_one_ref);
  38. _self->_base._has_one_ref = Marshal.GetFunctionPointerForDelegate(_ds2);
  39. _ds3 = new cef_resource_request_handler_t.has_at_least_one_ref_delegate(has_at_least_one_ref);
  40. _self->_base._has_at_least_one_ref = Marshal.GetFunctionPointerForDelegate(_ds3);
  41. _ds4 = new cef_resource_request_handler_t.get_cookie_access_filter_delegate(get_cookie_access_filter);
  42. _self->_get_cookie_access_filter = Marshal.GetFunctionPointerForDelegate(_ds4);
  43. _ds5 = new cef_resource_request_handler_t.on_before_resource_load_delegate(on_before_resource_load);
  44. _self->_on_before_resource_load = Marshal.GetFunctionPointerForDelegate(_ds5);
  45. _ds6 = new cef_resource_request_handler_t.get_resource_handler_delegate(get_resource_handler);
  46. _self->_get_resource_handler = Marshal.GetFunctionPointerForDelegate(_ds6);
  47. _ds7 = new cef_resource_request_handler_t.on_resource_redirect_delegate(on_resource_redirect);
  48. _self->_on_resource_redirect = Marshal.GetFunctionPointerForDelegate(_ds7);
  49. _ds8 = new cef_resource_request_handler_t.on_resource_response_delegate(on_resource_response);
  50. _self->_on_resource_response = Marshal.GetFunctionPointerForDelegate(_ds8);
  51. _ds9 = new cef_resource_request_handler_t.get_resource_response_filter_delegate(get_resource_response_filter);
  52. _self->_get_resource_response_filter = Marshal.GetFunctionPointerForDelegate(_ds9);
  53. _dsa = new cef_resource_request_handler_t.on_resource_load_complete_delegate(on_resource_load_complete);
  54. _self->_on_resource_load_complete = Marshal.GetFunctionPointerForDelegate(_dsa);
  55. _dsb = new cef_resource_request_handler_t.on_protocol_execution_delegate(on_protocol_execution);
  56. _self->_on_protocol_execution = Marshal.GetFunctionPointerForDelegate(_dsb);
  57. }
  58. ~CefResourceRequestHandler()
  59. {
  60. Dispose(false);
  61. }
  62. protected virtual void Dispose(bool disposing)
  63. {
  64. if (_self != null)
  65. {
  66. cef_resource_request_handler_t.Free(_self);
  67. _self = null;
  68. }
  69. }
  70. private void add_ref(cef_resource_request_handler_t* self)
  71. {
  72. if (Interlocked.Increment(ref _refct) == 1)
  73. {
  74. lock (_roots) { _roots.Add((IntPtr)_self, this); }
  75. }
  76. }
  77. private int release(cef_resource_request_handler_t* self)
  78. {
  79. if (Interlocked.Decrement(ref _refct) == 0)
  80. {
  81. lock (_roots) { _roots.Remove((IntPtr)_self); }
  82. return 1;
  83. }
  84. return 0;
  85. }
  86. private int has_one_ref(cef_resource_request_handler_t* self)
  87. {
  88. return _refct == 1 ? 1 : 0;
  89. }
  90. private int has_at_least_one_ref(cef_resource_request_handler_t* self)
  91. {
  92. return _refct != 0 ? 1 : 0;
  93. }
  94. internal cef_resource_request_handler_t* ToNative()
  95. {
  96. add_ref(_self);
  97. return _self;
  98. }
  99. [Conditional("DEBUG")]
  100. private void CheckSelf(cef_resource_request_handler_t* self)
  101. {
  102. if (_self != self) throw ExceptionBuilder.InvalidSelfReference();
  103. }
  104. }
  105. }