CefServerHandler.g.cs 5.0 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 CefServerHandler
  14. {
  15. private static Dictionary<IntPtr, CefServerHandler> _roots = new Dictionary<IntPtr, CefServerHandler>();
  16. private int _refct;
  17. private cef_server_handler_t* _self;
  18. private cef_server_handler_t.add_ref_delegate _ds0;
  19. private cef_server_handler_t.release_delegate _ds1;
  20. private cef_server_handler_t.has_one_ref_delegate _ds2;
  21. private cef_server_handler_t.has_at_least_one_ref_delegate _ds3;
  22. private cef_server_handler_t.on_server_created_delegate _ds4;
  23. private cef_server_handler_t.on_server_destroyed_delegate _ds5;
  24. private cef_server_handler_t.on_client_connected_delegate _ds6;
  25. private cef_server_handler_t.on_client_disconnected_delegate _ds7;
  26. private cef_server_handler_t.on_http_request_delegate _ds8;
  27. private cef_server_handler_t.on_web_socket_request_delegate _ds9;
  28. private cef_server_handler_t.on_web_socket_connected_delegate _dsa;
  29. private cef_server_handler_t.on_web_socket_message_delegate _dsb;
  30. protected CefServerHandler()
  31. {
  32. _self = cef_server_handler_t.Alloc();
  33. _ds0 = new cef_server_handler_t.add_ref_delegate(add_ref);
  34. _self->_base._add_ref = Marshal.GetFunctionPointerForDelegate(_ds0);
  35. _ds1 = new cef_server_handler_t.release_delegate(release);
  36. _self->_base._release = Marshal.GetFunctionPointerForDelegate(_ds1);
  37. _ds2 = new cef_server_handler_t.has_one_ref_delegate(has_one_ref);
  38. _self->_base._has_one_ref = Marshal.GetFunctionPointerForDelegate(_ds2);
  39. _ds3 = new cef_server_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_server_handler_t.on_server_created_delegate(on_server_created);
  42. _self->_on_server_created = Marshal.GetFunctionPointerForDelegate(_ds4);
  43. _ds5 = new cef_server_handler_t.on_server_destroyed_delegate(on_server_destroyed);
  44. _self->_on_server_destroyed = Marshal.GetFunctionPointerForDelegate(_ds5);
  45. _ds6 = new cef_server_handler_t.on_client_connected_delegate(on_client_connected);
  46. _self->_on_client_connected = Marshal.GetFunctionPointerForDelegate(_ds6);
  47. _ds7 = new cef_server_handler_t.on_client_disconnected_delegate(on_client_disconnected);
  48. _self->_on_client_disconnected = Marshal.GetFunctionPointerForDelegate(_ds7);
  49. _ds8 = new cef_server_handler_t.on_http_request_delegate(on_http_request);
  50. _self->_on_http_request = Marshal.GetFunctionPointerForDelegate(_ds8);
  51. _ds9 = new cef_server_handler_t.on_web_socket_request_delegate(on_web_socket_request);
  52. _self->_on_web_socket_request = Marshal.GetFunctionPointerForDelegate(_ds9);
  53. _dsa = new cef_server_handler_t.on_web_socket_connected_delegate(on_web_socket_connected);
  54. _self->_on_web_socket_connected = Marshal.GetFunctionPointerForDelegate(_dsa);
  55. _dsb = new cef_server_handler_t.on_web_socket_message_delegate(on_web_socket_message);
  56. _self->_on_web_socket_message = Marshal.GetFunctionPointerForDelegate(_dsb);
  57. }
  58. ~CefServerHandler()
  59. {
  60. Dispose(false);
  61. }
  62. protected virtual void Dispose(bool disposing)
  63. {
  64. if (_self != null)
  65. {
  66. cef_server_handler_t.Free(_self);
  67. _self = null;
  68. }
  69. }
  70. private void add_ref(cef_server_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_server_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_server_handler_t* self)
  87. {
  88. return _refct == 1 ? 1 : 0;
  89. }
  90. private int has_at_least_one_ref(cef_server_handler_t* self)
  91. {
  92. return _refct != 0 ? 1 : 0;
  93. }
  94. internal cef_server_handler_t* ToNative()
  95. {
  96. add_ref(_self);
  97. return _self;
  98. }
  99. [Conditional("DEBUG")]
  100. private void CheckSelf(cef_server_handler_t* self)
  101. {
  102. if (_self != self) throw ExceptionBuilder.InvalidSelfReference();
  103. }
  104. }
  105. }