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.

217 lines
3.3 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name :
  4. w3cache.cxx
  5. Abstract:
  6. Exposes the cache manager (and thus cache) to everyone
  7. Author:
  8. Bilal Alam (balam) 11-Nov-2000
  9. Environment:
  10. Win32 - User Mode
  11. Project:
  12. ULW3.DLL
  13. --*/
  14. #include "precomp.hxx"
  15. DECLARE_DEBUG_PRINTS_OBJECT();
  16. DECLARE_DEBUG_VARIABLE();
  17. DECLARE_PLATFORM_TYPE();
  18. HRESULT
  19. W3CacheInitialize(
  20. IMSAdminBase * pAdminBase
  21. )
  22. /*++
  23. Routine Description:
  24. Initialize cache manager
  25. Arguments:
  26. pAdminBase - Admin base object used for stuff
  27. Return Value:
  28. HRESULT
  29. --*/
  30. {
  31. HRESULT hr = NO_ERROR;
  32. DBG_ASSERT( g_pCacheManager == NULL );
  33. //
  34. // Allocate an initialize the cache manager (there is only one manager)
  35. //
  36. g_pCacheManager = new CACHE_MANAGER;
  37. if ( g_pCacheManager == NULL )
  38. {
  39. return HRESULT_FROM_WIN32( GetLastError() );
  40. }
  41. hr = g_pCacheManager->Initialize( pAdminBase );
  42. if ( FAILED( hr ) )
  43. {
  44. delete g_pCacheManager;
  45. g_pCacheManager = NULL;
  46. return hr;
  47. }
  48. return NO_ERROR;
  49. }
  50. VOID
  51. W3CacheTerminate(
  52. VOID
  53. )
  54. /*++
  55. Routine Description:
  56. Cleanup the cache manager
  57. Arguments:
  58. None
  59. Return Value:
  60. None
  61. --*/
  62. {
  63. if ( g_pCacheManager != NULL )
  64. {
  65. g_pCacheManager->Terminate();
  66. delete g_pCacheManager;
  67. g_pCacheManager = NULL;
  68. }
  69. }
  70. HRESULT
  71. W3CacheRegisterCache(
  72. OBJECT_CACHE * pObjectCache
  73. )
  74. /*++
  75. Routine Description:
  76. Register a cache with the manager
  77. Arguments:
  78. pObjectCache - Object cache to register
  79. Return Value:
  80. HRESULT
  81. --*/
  82. {
  83. if ( g_pCacheManager == NULL )
  84. {
  85. DBG_ASSERT( FALSE );
  86. return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED );
  87. }
  88. return g_pCacheManager->AddNewCache( pObjectCache );
  89. }
  90. HRESULT
  91. W3CacheUnregisterCache(
  92. OBJECT_CACHE * pObjectCache
  93. )
  94. /*++
  95. Routine Description:
  96. Unregister a cache with the manager
  97. Arguments:
  98. pObjectCache - Object cache to unregister
  99. Return Value:
  100. HRESULT
  101. --*/
  102. {
  103. if ( g_pCacheManager == NULL )
  104. {
  105. DBG_ASSERT( FALSE );
  106. return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED );
  107. }
  108. return g_pCacheManager->RemoveCache( pObjectCache );
  109. }
  110. HRESULT
  111. W3CacheDoMetadataInvalidation(
  112. WCHAR * pszMetabasePath,
  113. DWORD
  114. )
  115. /*++
  116. Routine Description:
  117. Drive invalidation of caches based on metadata changing
  118. Arguments:
  119. pszMetabasePath - Metabase path which changed (includes the "LM/W3SVC/<>" stuff)
  120. cchMetabasePath - Unused
  121. Return Value:
  122. HRESULT
  123. --*/
  124. {
  125. if ( pszMetabasePath == NULL )
  126. {
  127. DBG_ASSERT( FALSE );
  128. return HRESULT_FROM_WIN32( ERROR_INVALID_PARAMETER );
  129. }
  130. if ( g_pCacheManager != NULL )
  131. {
  132. g_pCacheManager->HandleMetadataInvalidation( pszMetabasePath );
  133. }
  134. return NO_ERROR;
  135. }
  136. VOID
  137. W3CacheFlushAllCaches(
  138. VOID
  139. )
  140. /*++
  141. Routine Description:
  142. Flush all caches
  143. Arguments:
  144. None
  145. Return Value:
  146. None
  147. --*/
  148. {
  149. DBG_ASSERT( g_pCacheManager != NULL );
  150. g_pCacheManager->FlushAllCaches();
  151. }