CefUrlRequestClient.g.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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 CefUrlRequestClient
  14. {
  15. private static Dictionary<IntPtr, CefUrlRequestClient> _roots = new Dictionary<IntPtr, CefUrlRequestClient>();
  16. private int _refct;
  17. private cef_urlrequest_client_t* _self;
  18. internal static CefUrlRequestClient FromNativeOrNull(cef_urlrequest_client_t* ptr)
  19. {
  20. CefUrlRequestClient value = null;
  21. bool found;
  22. lock (_roots)
  23. {
  24. found = _roots.TryGetValue((IntPtr)ptr, out value);
  25. // as we're getting the ref from the outside, it's our responsibility to decrement it
  26. value.release(ptr);
  27. }
  28. return found ? value : null;
  29. }
  30. internal static CefUrlRequestClient FromNative(cef_urlrequest_client_t* ptr)
  31. {
  32. var value = FromNativeOrNull(ptr);
  33. if (value == null) throw ExceptionBuilder.ObjectNotFound();
  34. return value;
  35. }
  36. private cef_urlrequest_client_t.add_ref_delegate _ds0;
  37. private cef_urlrequest_client_t.release_delegate _ds1;
  38. private cef_urlrequest_client_t.has_one_ref_delegate _ds2;
  39. private cef_urlrequest_client_t.has_at_least_one_ref_delegate _ds3;
  40. private cef_urlrequest_client_t.on_request_complete_delegate _ds4;
  41. private cef_urlrequest_client_t.on_upload_progress_delegate _ds5;
  42. private cef_urlrequest_client_t.on_download_progress_delegate _ds6;
  43. private cef_urlrequest_client_t.on_download_data_delegate _ds7;
  44. private cef_urlrequest_client_t.get_auth_credentials_delegate _ds8;
  45. protected CefUrlRequestClient()
  46. {
  47. _self = cef_urlrequest_client_t.Alloc();
  48. _ds0 = new cef_urlrequest_client_t.add_ref_delegate(add_ref);
  49. _self->_base._add_ref = Marshal.GetFunctionPointerForDelegate(_ds0);
  50. _ds1 = new cef_urlrequest_client_t.release_delegate(release);
  51. _self->_base._release = Marshal.GetFunctionPointerForDelegate(_ds1);
  52. _ds2 = new cef_urlrequest_client_t.has_one_ref_delegate(has_one_ref);
  53. _self->_base._has_one_ref = Marshal.GetFunctionPointerForDelegate(_ds2);
  54. _ds3 = new cef_urlrequest_client_t.has_at_least_one_ref_delegate(has_at_least_one_ref);
  55. _self->_base._has_at_least_one_ref = Marshal.GetFunctionPointerForDelegate(_ds3);
  56. _ds4 = new cef_urlrequest_client_t.on_request_complete_delegate(on_request_complete);
  57. _self->_on_request_complete = Marshal.GetFunctionPointerForDelegate(_ds4);
  58. _ds5 = new cef_urlrequest_client_t.on_upload_progress_delegate(on_upload_progress);
  59. _self->_on_upload_progress = Marshal.GetFunctionPointerForDelegate(_ds5);
  60. _ds6 = new cef_urlrequest_client_t.on_download_progress_delegate(on_download_progress);
  61. _self->_on_download_progress = Marshal.GetFunctionPointerForDelegate(_ds6);
  62. _ds7 = new cef_urlrequest_client_t.on_download_data_delegate(on_download_data);
  63. _self->_on_download_data = Marshal.GetFunctionPointerForDelegate(_ds7);
  64. _ds8 = new cef_urlrequest_client_t.get_auth_credentials_delegate(get_auth_credentials);
  65. _self->_get_auth_credentials = Marshal.GetFunctionPointerForDelegate(_ds8);
  66. }
  67. ~CefUrlRequestClient()
  68. {
  69. Dispose(false);
  70. }
  71. protected virtual void Dispose(bool disposing)
  72. {
  73. if (_self != null)
  74. {
  75. cef_urlrequest_client_t.Free(_self);
  76. _self = null;
  77. }
  78. }
  79. private void add_ref(cef_urlrequest_client_t* self)
  80. {
  81. if (Interlocked.Increment(ref _refct) == 1)
  82. {
  83. lock (_roots) { _roots.Add((IntPtr)_self, this); }
  84. }
  85. }
  86. private int release(cef_urlrequest_client_t* self)
  87. {
  88. if (Interlocked.Decrement(ref _refct) == 0)
  89. {
  90. lock (_roots) { _roots.Remove((IntPtr)_self); }
  91. return 1;
  92. }
  93. return 0;
  94. }
  95. private int has_one_ref(cef_urlrequest_client_t* self)
  96. {
  97. return _refct == 1 ? 1 : 0;
  98. }
  99. private int has_at_least_one_ref(cef_urlrequest_client_t* self)
  100. {
  101. return _refct != 0 ? 1 : 0;
  102. }
  103. internal cef_urlrequest_client_t* ToNative()
  104. {
  105. add_ref(_self);
  106. return _self;
  107. }
  108. [Conditional("DEBUG")]
  109. private void CheckSelf(cef_urlrequest_client_t* self)
  110. {
  111. if (_self != self) throw ExceptionBuilder.InvalidSelfReference();
  112. }
  113. }
  114. }