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.

231 lines
4.4 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( OBJECT_CACHE * pObjectCache )
  65. : CACHE_ENTRY( pObjectCache ),
  66. _strPhysicalPath( _achPhysicalPath, sizeof( _achPhysicalPath ) ),
  67. _strInvalidationUrl( _achInvalidationUrl, sizeof( _achInvalidationUrl ) )
  68. {
  69. _dwSignature = UL_RESPONSE_CACHE_ENTRY_SIGNATURE;
  70. }
  71. virtual ~UL_RESPONSE_CACHE_ENTRY();
  72. VOID *
  73. operator new(
  74. size_t size
  75. )
  76. {
  77. DBG_ASSERT( size == sizeof( UL_RESPONSE_CACHE_ENTRY ) );
  78. DBG_ASSERT( sm_pachUlResponseCache != NULL );
  79. return sm_pachUlResponseCache->Alloc();
  80. }
  81. VOID
  82. operator delete(
  83. VOID * pUlResponseCache
  84. )
  85. {
  86. DBG_ASSERT( pUlResponseCache != NULL );
  87. DBG_ASSERT( sm_pachUlResponseCache != NULL );
  88. DBG_REQUIRE( sm_pachUlResponseCache->Free( pUlResponseCache ) );
  89. }
  90. BOOL
  91. QueryIsOkToFlushDirmon(
  92. WCHAR * pszPath,
  93. DWORD cchPath
  94. );
  95. STRU *
  96. QueryMetadataPath(
  97. VOID
  98. )
  99. {
  100. return _cacheKey.QueryMetadataPath();
  101. }
  102. BOOL
  103. QueryIsOkToFlushMetadata(
  104. WCHAR * pszPath,
  105. DWORD cchPath
  106. );
  107. CACHE_KEY *
  108. QueryCacheKey(
  109. VOID
  110. ) const
  111. {
  112. return (CACHE_KEY*) &_cacheKey;
  113. }
  114. BOOL
  115. CheckSignature(
  116. VOID
  117. ) const
  118. {
  119. return _dwSignature == UL_RESPONSE_CACHE_ENTRY_SIGNATURE;
  120. }
  121. HRESULT
  122. Create(
  123. STRU & strMetadataPath,
  124. STRU & strPhysical,
  125. STRU & strInvalidationUrl
  126. );
  127. static
  128. HRESULT
  129. Initialize(
  130. VOID
  131. );
  132. static
  133. VOID
  134. Terminate(
  135. VOID
  136. );
  137. private:
  138. DWORD _dwSignature;
  139. UL_RESPONSE_CACHE_KEY _cacheKey;
  140. STRU _strPhysicalPath;
  141. WCHAR _achPhysicalPath[ 64 ];
  142. STRU _strInvalidationUrl;
  143. WCHAR _achInvalidationUrl[ 64 ];
  144. static ALLOC_CACHE_HANDLER * sm_pachUlResponseCache;
  145. };
  146. class UL_RESPONSE_CACHE : public OBJECT_CACHE
  147. {
  148. public:
  149. UL_RESPONSE_CACHE();
  150. virtual ~UL_RESPONSE_CACHE();
  151. HRESULT
  152. Initialize(
  153. VOID
  154. );
  155. VOID
  156. Terminate(
  157. VOID
  158. )
  159. {
  160. return UL_RESPONSE_CACHE_ENTRY::Terminate();
  161. }
  162. WCHAR *
  163. QueryName(
  164. VOID
  165. ) const
  166. {
  167. return L"UL_RESPONSE_CACHE";
  168. }
  169. BOOL
  170. QueryUlCacheEnabled(
  171. VOID
  172. ) const
  173. {
  174. return _fUlCacheEnabled;
  175. }
  176. BOOL
  177. CheckUlCacheability(
  178. W3_CONTEXT * pW3Context
  179. );
  180. HRESULT
  181. SetupUlCachedResponse(
  182. W3_CONTEXT * pW3Context,
  183. STRU & strFullUrl,
  184. STRU & strPhysicalPath
  185. );
  186. private:
  187. BOOL _fUlCacheEnabled;
  188. };
  189. #endif