CefResourceHandler.g.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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 CefResourceHandler
  14. {
  15. private static Dictionary<IntPtr, CefResourceHandler> _roots = new Dictionary<IntPtr, CefResourceHandler>();
  16. private int _refct;
  17. private cef_resource_handler_t* _self;
  18. private cef_resource_handler_t.add_ref_delegate _ds0;
  19. private cef_resource_handler_t.release_delegate _ds1;
  20. private cef_resource_handler_t.has_one_ref_delegate _ds2;
  21. private cef_resource_handler_t.has_at_least_one_ref_delegate _ds3;
  22. private cef_resource_handler_t.open_delegate _ds4;
  23. private cef_resource_handler_t.process_request_delegate _ds5;
  24. private cef_resource_handler_t.get_response_headers_delegate _ds6;
  25. private cef_resource_handler_t.skip_delegate _ds7;
  26. private cef_resource_handler_t.read_delegate _ds8;
  27. private cef_resource_handler_t.read_response_delegate _ds9;
  28. private cef_resource_handler_t.cancel_delegate _dsa;
  29. protected CefResourceHandler()
  30. {
  31. _self = cef_resource_handler_t.Alloc();
  32. _ds0 = new cef_resource_handler_t.add_ref_delegate(add_ref);
  33. _self->_base._add_ref = Marshal.GetFunctionPointerForDelegate(_ds0);
  34. _ds1 = new cef_resource_handler_t.release_delegate(release);
  35. _self->_base._release = Marshal.GetFunctionPointerForDelegate(_ds1);
  36. _ds2 = new cef_resource_handler_t.has_one_ref_delegate(has_one_ref);
  37. _self->_base._has_one_ref = Marshal.GetFunctionPointerForDelegate(_ds2);
  38. _ds3 = new cef_resource_handler_t.has_at_least_one_ref_delegate(has_at_least_one_ref);
  39. _self->_base._has_at_least_one_ref = Marshal.GetFunctionPointerForDelegate(_ds3);
  40. _ds4 = new cef_resource_handler_t.open_delegate(open);
  41. _self->_open = Marshal.GetFunctionPointerForDelegate(_ds4);
  42. _ds5 = new cef_resource_handler_t.process_request_delegate(process_request);
  43. _self->_process_request = Marshal.GetFunctionPointerForDelegate(_ds5);
  44. _ds6 = new cef_resource_handler_t.get_response_headers_delegate(get_response_headers);
  45. _self->_get_response_headers = Marshal.GetFunctionPointerForDelegate(_ds6);
  46. _ds7 = new cef_resource_handler_t.skip_delegate(skip);
  47. _self->_skip = Marshal.GetFunctionPointerForDelegate(_ds7);
  48. _ds8 = new cef_resource_handler_t.read_delegate(read);
  49. _self->_read = Marshal.GetFunctionPointerForDelegate(_ds8);
  50. _ds9 = new cef_resource_handler_t.read_response_delegate(read_response);
  51. _self->_read_response = Marshal.GetFunctionPointerForDelegate(_ds9);
  52. _dsa = new cef_resource_handler_t.cancel_delegate(cancel);
  53. _self->_cancel = Marshal.GetFunctionPointerForDelegate(_dsa);
  54. }
  55. ~CefResourceHandler()
  56. {
  57. Dispose(false);
  58. }
  59. private void Dispose()
  60. {
  61. Dispose(true);
  62. GC.SuppressFinalize(this);
  63. }
  64. protected virtual void Dispose(bool disposing)
  65. {
  66. if (_self != null)
  67. {
  68. cef_resource_handler_t.Free(_self);
  69. _self = null;
  70. }
  71. }
  72. private void add_ref(cef_resource_handler_t* self)
  73. {
  74. if (Interlocked.Increment(ref _refct) == 1)
  75. {
  76. lock (_roots) { _roots.Add((IntPtr)_self, this); }
  77. }
  78. }
  79. private int release(cef_resource_handler_t* self)
  80. {
  81. if (Interlocked.Decrement(ref _refct) == 0)
  82. {
  83. lock (_roots) { _roots.Remove((IntPtr)_self); }
  84. Dispose();
  85. return 1;
  86. }
  87. return 0;
  88. }
  89. private int has_one_ref(cef_resource_handler_t* self)
  90. {
  91. return _refct == 1 ? 1 : 0;
  92. }
  93. private int has_at_least_one_ref(cef_resource_handler_t* self)
  94. {
  95. return _refct != 0 ? 1 : 0;
  96. }
  97. internal cef_resource_handler_t* ToNative()
  98. {
  99. add_ref(_self);
  100. return _self;
  101. }
  102. [Conditional("DEBUG")]
  103. private void CheckSelf(cef_resource_handler_t* self)
  104. {
  105. if (_self != self) throw ExceptionBuilder.InvalidSelfReference();
  106. }
  107. }
  108. }