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.

214 lines
4.1 KiB

  1. #ifndef CACHEMGR_HXX
  2. #define CACHEMGR_HXX
  3. #include "priv.h"
  4. class CacheMgr
  5. {
  6. public:
  7. CacheMgr ();
  8. virtual ~CacheMgr();
  9. VOID
  10. InvalidateCache ();
  11. VOID
  12. InvalidateCacheForUser (
  13. CLogonUserData *pUser );
  14. virtual VOID
  15. EndReadCache (VOID);
  16. VOID
  17. Shutdown ();
  18. static LPVOID
  19. Allocator(DWORD cb);
  20. inline BOOL
  21. bValid() CONST {return m_bValid;}
  22. protected:
  23. PVOID
  24. BeginReadCache (
  25. PCINETMONPORT pIniPort);
  26. virtual BOOL
  27. FreeBuffer (
  28. PCINETMONPORT pIniPort,
  29. PVOID pData) = 0;
  30. virtual BOOL
  31. FetchData (
  32. PCINETMONPORT pIniPort,
  33. PVOID *ppData) = 0;
  34. protected:
  35. BOOL m_bValid;
  36. PCINETMONPORT m_pIniPort;
  37. PVOID m_pData;
  38. private:
  39. typedef struct {
  40. CacheMgr *pCache;
  41. PCINETMONPORT pIniPort;
  42. CSid *pSidToken;
  43. } THREADCONTEXT;
  44. typedef THREADCONTEXT *PTHREADCONTEXT;
  45. typedef enum {
  46. CACHE_STATE_INIT = 0,
  47. CACHE_STATE_ACCESSED_VALID,
  48. CACHE_STATE_DATA_VALID,
  49. CACHE_STATE_ACCESSED_VALID_AGAIN,
  50. CACHE_STATE_NOT_ACCESSED_VALID_AGAIN
  51. } CACHESTATE;
  52. CACHESTATE m_dwState;
  53. HANDLE m_hDataReadyEvent;
  54. HANDLE m_hHitEvent;
  55. HANDLE m_hInvalidateCacheEvent;
  56. HANDLE m_hThread;
  57. BOOL m_bCacheStopped;
  58. BOOL m_bAccessed;
  59. BOOL m_bInvalidateFlag;
  60. DWORD m_dwThreadRefCount;
  61. CCriticalSection CacheRead;
  62. CCriticalSection CacheData;
  63. CUserData m_CurUser;
  64. private:
  65. VOID
  66. AttachThreadHandle (
  67. HANDLE hThread
  68. );
  69. HANDLE
  70. GetThreadHandle (
  71. VOID
  72. );
  73. VOID
  74. ReleaseThreadHandle (
  75. VOID
  76. );
  77. VOID
  78. SetState (
  79. PCINETMONPORT pIniPort,
  80. CACHESTATE dwState,
  81. BOOL bNewData,
  82. PVOID pNewData);
  83. BOOL
  84. SetupAsyncFetch (
  85. PCINETMONPORT pIniPort);
  86. VOID
  87. TransitState (
  88. PCINETMONPORT pIniPort);
  89. static VOID
  90. WorkingThread (
  91. PTHREADCONTEXT pThreadData);
  92. BOOL
  93. GetFetchTime (
  94. PCINETMONPORT pIniPort,
  95. LPDWORD pdwTime,
  96. PVOID *ppData);
  97. inline DWORD
  98. GetTimeDiff (
  99. DWORD t0,
  100. DWORD t1);
  101. VOID
  102. _InvalidateCache ();
  103. };
  104. class GetPrinterCache: public CacheMgr
  105. {
  106. public:
  107. GetPrinterCache (
  108. PCINETMONPORT pIniPort);
  109. ~GetPrinterCache (
  110. VOID);
  111. typedef struct {
  112. BOOL bRet;
  113. DWORD dwLastError;
  114. DWORD cbSize;
  115. PPRINTER_INFO_2 pInfo;
  116. } GETPRINTER_CACHEDATA;
  117. typedef GETPRINTER_CACHEDATA * PGETPRINTER_CACHEDATA;
  118. BOOL
  119. BeginReadCache (
  120. PPRINTER_INFO_2 *ppInfo);
  121. protected:
  122. virtual BOOL
  123. FreeBuffer (
  124. PCINETMONPORT pIniPort,
  125. PVOID pData);
  126. virtual BOOL
  127. FetchData (
  128. PCINETMONPORT pIniPort,
  129. LPVOID *ppData);
  130. private:
  131. PCINETMONPORT m_pIniPort;
  132. };
  133. class EnumJobsCache: public CacheMgr
  134. {
  135. public:
  136. EnumJobsCache (
  137. PCINETMONPORT pIniPort);
  138. ~EnumJobsCache (
  139. VOID);
  140. BOOL
  141. BeginReadCache (
  142. LPPPJOB_ENUM *ppje);
  143. VOID
  144. EndReadCache (
  145. VOID);
  146. protected:
  147. virtual BOOL
  148. FreeBuffer (
  149. PCINETMONPORT pIniPort,
  150. PVOID pData);
  151. virtual BOOL
  152. FetchData (
  153. PCINETMONPORT pIniPort,
  154. LPVOID *ppData);
  155. private:
  156. typedef struct {
  157. BOOL bRet;
  158. DWORD dwLastError;
  159. DWORD cbSize;
  160. LPPPJOB_ENUM pje;
  161. } ENUMJOBS_CACHEDATA;
  162. typedef ENUMJOBS_CACHEDATA * PENUMJOBS_CACHEDATA;
  163. PCINETMONPORT m_pIniPort;
  164. };
  165. #endif // #ifndef CACHEMGR_H