Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

136 lines
2.6 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 2001
  3. Module Name:
  4. Cookie.hxx
  5. Abstract:
  6. HTTP2 Cookie management functions.
  7. Author:
  8. KamenM 09-18-01 Created
  9. Revision History:
  10. --*/
  11. #if _MSC_VER >= 1200
  12. #pragma once
  13. #endif
  14. #ifndef __COOKIE_HXX__
  15. #define __COOKIE_HXX__
  16. class CookieCollection; // forward
  17. extern CookieCollection *g_pServerCookieCollection;
  18. extern CookieCollection *g_pInProxyCookieCollection;
  19. extern CookieCollection *g_pOutProxyCookieCollection;
  20. // the CookieCollection. Currently a linked list. Try to make it
  21. // more efficient when we have time (especially a reader/writer lock)
  22. class CookieCollection
  23. {
  24. public:
  25. CookieCollection (
  26. OUT RPC_STATUS *RpcStatus
  27. ) : Mutex (RpcStatus)
  28. {
  29. RpcpInitializeListHead(&ListHead);
  30. }
  31. inline void LockCollection (
  32. void
  33. )
  34. {
  35. Mutex.Request();
  36. }
  37. void UnlockCollection (
  38. void
  39. )
  40. {
  41. Mutex.Clear();
  42. }
  43. HTTP2VirtualConnection *FindElement (
  44. IN HTTP2ServerCookie *Cookie
  45. );
  46. void AddElement (
  47. IN HTTP2ServerCookie *Cookie
  48. )
  49. {
  50. Mutex.VerifyOwned();
  51. ASSERT(FindElement(Cookie) == NULL);
  52. RpcpfInsertHeadList(&ListHead, &Cookie->ListEntry);
  53. }
  54. void RemoveElement (
  55. IN HTTP2ServerCookie *Cookie
  56. )
  57. {
  58. Mutex.VerifyOwned();
  59. ASSERT(FindElement(Cookie) != NULL);
  60. RpcpfRemoveEntryList(&Cookie->ListEntry);
  61. }
  62. inline static RPC_STATUS InitializeServerCookieCollection (
  63. void
  64. )
  65. {
  66. return InitializeCookieCollection(&g_pServerCookieCollection);
  67. }
  68. inline static RPC_STATUS InitializeInProxyCookieCollection (
  69. void
  70. )
  71. {
  72. return InitializeCookieCollection(&g_pInProxyCookieCollection);
  73. }
  74. inline static RPC_STATUS InitializeOutProxyCookieCollection (
  75. void
  76. )
  77. {
  78. return InitializeCookieCollection(&g_pOutProxyCookieCollection);
  79. }
  80. private:
  81. static RPC_STATUS InitializeCookieCollection (
  82. IN OUT CookieCollection **CookieCollectionPtr
  83. );
  84. MUTEX Mutex;
  85. LIST_ENTRY ListHead;
  86. };
  87. inline CookieCollection *GetServerCookieCollection (void)
  88. {
  89. ASSERT(g_pServerCookieCollection != NULL);
  90. return g_pServerCookieCollection;
  91. }
  92. inline CookieCollection *GetInProxyCookieCollection (void)
  93. {
  94. ASSERT(g_pInProxyCookieCollection != NULL);
  95. return g_pInProxyCookieCollection;
  96. }
  97. inline CookieCollection *GetOutProxyCookieCollection (void)
  98. {
  99. ASSERT(g_pOutProxyCookieCollection != NULL);
  100. return g_pOutProxyCookieCollection;
  101. }
  102. #endif // __COOKIE_HXX__