Leaked source code of windows server 2003
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.

243 lines
4.9 KiB

  1. #ifndef _ULCACHE_HXX_
  2. #define _ULCACHE_HXX_
  3. #include <usercache.hxx>
  4. class UL_RESPONSE_CACHE_KEY : public CACHE_KEY
  5. {
  6. public:
  7. UL_RESPONSE_CACHE_KEY()
  8. : _strKey( _achKey, sizeof( _achKey ) ),
  9. _pszKey( NULL ),
  10. _cchKey( 0 )
  11. {
  12. }
  13. HRESULT
  14. CreateCacheKey(
  15. WCHAR * pszKey,
  16. DWORD cchKey,
  17. BOOL fCopy
  18. );
  19. BOOL
  20. QueryIsEqual(
  21. const CACHE_KEY * pCompareKey
  22. ) const
  23. {
  24. UL_RESPONSE_CACHE_KEY * pUriKey = (UL_RESPONSE_CACHE_KEY*) pCompareKey;
  25. DBG_ASSERT( pUriKey != NULL );
  26. return _cchKey == pUriKey->_cchKey &&
  27. !wcscmp( _pszKey, pUriKey->_pszKey );
  28. }
  29. WCHAR *
  30. QueryUrl(
  31. VOID
  32. ) const
  33. {
  34. return _pszKey;
  35. }
  36. STRU *
  37. QueryMetadataPath(
  38. VOID
  39. )
  40. {
  41. return &_strKey;
  42. }
  43. DWORD
  44. QueryKeyHash(
  45. VOID
  46. ) const
  47. {
  48. return HashString( _pszKey );
  49. }
  50. private:
  51. WCHAR _achKey[ 64 ];
  52. STRU _strKey;
  53. WCHAR * _pszKey;
  54. DWORD _cchKey;
  55. };
  56. //
  57. // UL response cache entry
  58. //
  59. #define UL_RESPONSE_CACHE_ENTRY_SIGNATURE ((DWORD)'CRLU')
  60. #define UL_RESPONSE_CACHE_ENTRY_SIGNATURE_FREE ((DWORD)'xrlu')
  61. class UL_RESPONSE_CACHE_ENTRY : public CACHE_ENTRY
  62. {
  63. public:
  64. UL_RESPONSE_CACHE_ENTRY(
  65. OBJECT_CACHE * pObjectCache,
  66. DWORD cTTLOverride
  67. )
  68. : CACHE_ENTRY( pObjectCache, cTTLOverride ),
  69. _strPhysicalPath( _achPhysicalPath, sizeof( _achPhysicalPath ) ),
  70. _strInvalidationUrl( _achInvalidationUrl, sizeof( _achInvalidationUrl ) )
  71. {
  72. _dwSignature = UL_RESPONSE_CACHE_ENTRY_SIGNATURE;
  73. }
  74. virtual ~UL_RESPONSE_CACHE_ENTRY();
  75. VOID *
  76. operator new(
  77. #if DBG
  78. size_t size
  79. #else
  80. size_t
  81. #endif
  82. )
  83. {
  84. DBG_ASSERT( size == sizeof( UL_RESPONSE_CACHE_ENTRY ) );
  85. DBG_ASSERT( sm_pachUlResponseCache != NULL );
  86. return sm_pachUlResponseCache->Alloc();
  87. }
  88. VOID
  89. operator delete(
  90. VOID * pUlResponseCache
  91. )
  92. {
  93. DBG_ASSERT( pUlResponseCache != NULL );
  94. DBG_ASSERT( sm_pachUlResponseCache != NULL );
  95. DBG_REQUIRE( sm_pachUlResponseCache->Free( pUlResponseCache ) );
  96. }
  97. BOOL
  98. QueryIsOkToFlushDirmon(
  99. WCHAR * pszPath,
  100. DWORD cchPath
  101. );
  102. STRU *
  103. QueryMetadataPath(
  104. VOID
  105. )
  106. {
  107. return _cacheKey.QueryMetadataPath();
  108. }
  109. BOOL
  110. QueryIsOkToFlushMetadata(
  111. WCHAR * pszPath,
  112. DWORD cchPath
  113. );
  114. CACHE_KEY *
  115. QueryCacheKey(
  116. VOID
  117. ) const
  118. {
  119. return (CACHE_KEY*) &_cacheKey;
  120. }
  121. BOOL
  122. CheckSignature(
  123. VOID
  124. ) const
  125. {
  126. return _dwSignature == UL_RESPONSE_CACHE_ENTRY_SIGNATURE;
  127. }
  128. HRESULT
  129. Create(
  130. STRU & strMetadataPath,
  131. STRU * pstrPhysical,
  132. STRU & strInvalidationUrl
  133. );
  134. static
  135. HRESULT
  136. Initialize(
  137. VOID
  138. );
  139. static
  140. VOID
  141. Terminate(
  142. VOID
  143. );
  144. private:
  145. DWORD _dwSignature;
  146. UL_RESPONSE_CACHE_KEY _cacheKey;
  147. STRU _strPhysicalPath;
  148. WCHAR _achPhysicalPath[ 64 ];
  149. STRU _strInvalidationUrl;
  150. WCHAR _achInvalidationUrl[ 64 ];
  151. static ALLOC_CACHE_HANDLER * sm_pachUlResponseCache;
  152. };
  153. class UL_RESPONSE_CACHE : public OBJECT_CACHE
  154. {
  155. public:
  156. UL_RESPONSE_CACHE();
  157. virtual ~UL_RESPONSE_CACHE();
  158. HRESULT
  159. Initialize(
  160. VOID
  161. );
  162. VOID
  163. Terminate(
  164. VOID
  165. )
  166. {
  167. return UL_RESPONSE_CACHE_ENTRY::Terminate();
  168. }
  169. WCHAR *
  170. QueryName(
  171. VOID
  172. ) const
  173. {
  174. return L"UL_RESPONSE_CACHE";
  175. }
  176. BOOL
  177. QueryUlCacheEnabled(
  178. VOID
  179. ) const
  180. {
  181. return _fUlCacheEnabled;
  182. }
  183. BOOL
  184. CheckUlCacheability(
  185. W3_CONTEXT * pW3Context
  186. );
  187. HRESULT
  188. SetupUlCachedResponse(
  189. W3_CONTEXT * pW3Context,
  190. STRU & strFullUrl,
  191. BOOL fAddDirmonInvalidator,
  192. STRU * pstrPhysicalPath,
  193. DWORD cTTLOverride = 0
  194. );
  195. private:
  196. UL_RESPONSE_CACHE(const UL_RESPONSE_CACHE &);
  197. void operator=(const UL_RESPONSE_CACHE &);
  198. BOOL _fUlCacheEnabled;
  199. };
  200. #endif