CefRenderProcessHandler.g.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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 CefRenderProcessHandler
  14. {
  15. private static Dictionary<IntPtr, CefRenderProcessHandler> _roots = new Dictionary<IntPtr, CefRenderProcessHandler>();
  16. private int _refct;
  17. private cef_render_process_handler_t* _self;
  18. private cef_render_process_handler_t.add_ref_delegate _ds0;
  19. private cef_render_process_handler_t.release_delegate _ds1;
  20. private cef_render_process_handler_t.has_one_ref_delegate _ds2;
  21. private cef_render_process_handler_t.has_at_least_one_ref_delegate _ds3;
  22. private cef_render_process_handler_t.on_web_kit_initialized_delegate _ds4;
  23. private cef_render_process_handler_t.on_browser_created_delegate _ds5;
  24. private cef_render_process_handler_t.on_browser_destroyed_delegate _ds6;
  25. private cef_render_process_handler_t.get_load_handler_delegate _ds7;
  26. private cef_render_process_handler_t.on_context_created_delegate _ds8;
  27. private cef_render_process_handler_t.on_context_released_delegate _ds9;
  28. private cef_render_process_handler_t.on_uncaught_exception_delegate _dsa;
  29. private cef_render_process_handler_t.on_focused_node_changed_delegate _dsb;
  30. private cef_render_process_handler_t.on_process_message_received_delegate _dsc;
  31. protected CefRenderProcessHandler()
  32. {
  33. _self = cef_render_process_handler_t.Alloc();
  34. _ds0 = new cef_render_process_handler_t.add_ref_delegate(add_ref);
  35. _self->_base._add_ref = Marshal.GetFunctionPointerForDelegate(_ds0);
  36. _ds1 = new cef_render_process_handler_t.release_delegate(release);
  37. _self->_base._release = Marshal.GetFunctionPointerForDelegate(_ds1);
  38. _ds2 = new cef_render_process_handler_t.has_one_ref_delegate(has_one_ref);
  39. _self->_base._has_one_ref = Marshal.GetFunctionPointerForDelegate(_ds2);
  40. _ds3 = new cef_render_process_handler_t.has_at_least_one_ref_delegate(has_at_least_one_ref);
  41. _self->_base._has_at_least_one_ref = Marshal.GetFunctionPointerForDelegate(_ds3);
  42. _ds4 = new cef_render_process_handler_t.on_web_kit_initialized_delegate(on_web_kit_initialized);
  43. _self->_on_web_kit_initialized = Marshal.GetFunctionPointerForDelegate(_ds4);
  44. _ds5 = new cef_render_process_handler_t.on_browser_created_delegate(on_browser_created);
  45. _self->_on_browser_created = Marshal.GetFunctionPointerForDelegate(_ds5);
  46. _ds6 = new cef_render_process_handler_t.on_browser_destroyed_delegate(on_browser_destroyed);
  47. _self->_on_browser_destroyed = Marshal.GetFunctionPointerForDelegate(_ds6);
  48. _ds7 = new cef_render_process_handler_t.get_load_handler_delegate(get_load_handler);
  49. _self->_get_load_handler = Marshal.GetFunctionPointerForDelegate(_ds7);
  50. _ds8 = new cef_render_process_handler_t.on_context_created_delegate(on_context_created);
  51. _self->_on_context_created = Marshal.GetFunctionPointerForDelegate(_ds8);
  52. _ds9 = new cef_render_process_handler_t.on_context_released_delegate(on_context_released);
  53. _self->_on_context_released = Marshal.GetFunctionPointerForDelegate(_ds9);
  54. _dsa = new cef_render_process_handler_t.on_uncaught_exception_delegate(on_uncaught_exception);
  55. _self->_on_uncaught_exception = Marshal.GetFunctionPointerForDelegate(_dsa);
  56. _dsb = new cef_render_process_handler_t.on_focused_node_changed_delegate(on_focused_node_changed);
  57. _self->_on_focused_node_changed = Marshal.GetFunctionPointerForDelegate(_dsb);
  58. _dsc = new cef_render_process_handler_t.on_process_message_received_delegate(on_process_message_received);
  59. _self->_on_process_message_received = Marshal.GetFunctionPointerForDelegate(_dsc);
  60. }
  61. ~CefRenderProcessHandler()
  62. {
  63. Dispose(false);
  64. }
  65. protected virtual void Dispose(bool disposing)
  66. {
  67. if (_self != null)
  68. {
  69. cef_render_process_handler_t.Free(_self);
  70. _self = null;
  71. }
  72. }
  73. private void add_ref(cef_render_process_handler_t* self)
  74. {
  75. if (Interlocked.Increment(ref _refct) == 1)
  76. {
  77. lock (_roots) { _roots.Add((IntPtr)_self, this); }
  78. }
  79. }
  80. private int release(cef_render_process_handler_t* self)
  81. {
  82. if (Interlocked.Decrement(ref _refct) == 0)
  83. {
  84. lock (_roots) { _roots.Remove((IntPtr)_self); }
  85. return 1;
  86. }
  87. return 0;
  88. }
  89. private int has_one_ref(cef_render_process_handler_t* self)
  90. {
  91. return _refct == 1 ? 1 : 0;
  92. }
  93. private int has_at_least_one_ref(cef_render_process_handler_t* self)
  94. {
  95. return _refct != 0 ? 1 : 0;
  96. }
  97. internal cef_render_process_handler_t* ToNative()
  98. {
  99. add_ref(_self);
  100. return _self;
  101. }
  102. [Conditional("DEBUG")]
  103. private void CheckSelf(cef_render_process_handler_t* self)
  104. {
  105. if (_self != self) throw ExceptionBuilder.InvalidSelfReference();
  106. }
  107. }
  108. }