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.

177 lines
6.0 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name: conmgr.hxx
  4. Abstract:
  5. Manages list of containers (CConList)
  6. Author:
  7. Adriaan Canter (adriaanc) 04-02-97
  8. --*/
  9. #ifndef _CONMGR_HXX
  10. #define _CONMGR_HXX
  11. // Total number of containers is 3: CONTENT, COOKIE and HISTORY.
  12. #define CONTENT 0
  13. #define COOKIE 1
  14. #define HISTORY 2
  15. #define NCONTAINERS 3
  16. // Alias for old names
  17. #define _coContent (_coContainer[CONTENT])
  18. #define _coCookies (_coContainer[COOKIE])
  19. #define _coHistory (_coContainer[HISTORY])
  20. class IE5_REGISTRYSET;
  21. /*-----------------------------------------------------------------------------
  22. Container manager class
  23. ---------------------------------------------------------------------------*/
  24. class CConMgr
  25. {
  26. private:
  27. DWORD _dwStatus;
  28. BOOL _fProfilesCapable, _fUsingBackupContainers;
  29. BOOL _fNewCacheVersion;
  30. DWORD _dwModifiedCount; // count last time we polled
  31. HANDLE _hMutexExtensible;// used to Mutex access to extensible containers registry
  32. DWORD _dwLastUnmap; // time of last UnMap sweep
  33. // Array of containers.
  34. CConList ConList;
  35. // Cached (not ref-counted - not needed) special containers
  36. URL_CONTAINER *_coContainer[NCONTAINERS];
  37. // Init function called by constructor.
  38. DWORD Init();
  39. // Initializes containers.
  40. DWORD InitFixedContainers();
  41. // Config info get and set functions.
  42. // Utilities.
  43. DWORD FindIndexFromPrefix(LPCSTR);
  44. BOOL PathPrefixMatch(LPCSTR, LPCSTR);
  45. DWORD ConfigureCache();
  46. DWORD GetCacheConfigInfo();
  47. DWORD SetLegacyCacheConfigInfo();
  48. DWORD GetSysRootCacheConfigInfo();
  49. void IncrementModifiedCount();
  50. DWORD ReadModifiedCount(BOOL fUpdateMemory);
  51. BOOL WasModified(BOOL fUpdateMemory);
  52. DWORD GetExtensibleCacheConfigInfo(BOOL fAlways);
  53. DWORD FindExtensibleContainer(LPCSTR Name);
  54. /* -----------------------
  55. We now longer need to support old versions of IE
  56. --------------------------
  57. VOID DiscoverRegistrySettings(IE5_REGISTRYSET* pie5rs);
  58. VOID DiscoverIE3Settings(IE5_REGISTRYSET* pie5rs);
  59. BOOL DiscoverIE4Settings(IE5_REGISTRYSET* pie5rs);
  60. BOOL DiscoverAnyIE5Settings(IE5_REGISTRYSET* pie5rs);
  61. */
  62. public:
  63. CConMgr();
  64. ~CConMgr();
  65. // static DWORD DeleteIE3Cache();
  66. // Methods specific to CConMgr.
  67. DWORD LoadContent();
  68. DWORD GetContainerInfo(LPSTR szUrl, LPINTERNET_CACHE_CONTAINER_INFOA pCI, LPDWORD pcbCI);
  69. DWORD GetStatus();
  70. DWORD FreeFindHandle(HANDLE hFind);
  71. BOOL DeleteFileIfNotRegistered(URL_CONTAINER *coDelete);
  72. DWORD CreateContainer(LPCSTR Name, LPCSTR CachePrefix, LPCSTR CachePath, DWORD KBCacheLimit, DWORD dwOptions);
  73. DWORD DeleteContainer(LPCSTR Name, DWORD dwOptions);
  74. HANDLE FindFirstContainer(DWORD *pdwModified, LPINTERNET_CACHE_CONTAINER_INFOA lpContainerInfo, LPDWORD lpdwContainerInfoBufferSize, DWORD dwOptions);
  75. BOOL FindNextContainer(HANDLE hFind, LPINTERNET_CACHE_CONTAINER_INFOA lpContainerInfo, LPDWORD lpdwContainerInfoBufferSize);
  76. #ifdef CHECKLOCK_PARANOID
  77. void CheckNoLocks(DWORD dwThreadId);
  78. #endif
  79. // Methods corresponding to URL_CONTAINER.
  80. DWORD UnlockUrl(LPCSTR);
  81. DWORD DeleteUrl(LPCSTR);
  82. BOOL GetHeaderData(DWORD, LPDWORD);
  83. BOOL SetHeaderData(DWORD, DWORD);
  84. BOOL IncrementHeaderData(DWORD, LPDWORD);
  85. DWORD SetUrlGroup(LPCSTR, DWORD, GROUPID);
  86. DWORD CreateUniqueFile(LPCSTR, DWORD, LPCSTR, LPTSTR, HANDLE*, BOOL = FALSE);
  87. DWORD AddUrl(AddUrlArg*);
  88. DWORD RetrieveUrl(LPCSTR, LPCACHE_ENTRY_INFOA*, LPDWORD, DWORD, DWORD);
  89. DWORD GetUrlInfo(LPCSTR, LPCACHE_ENTRY_INFOA*, LPDWORD, DWORD, DWORD, DWORD);
  90. DWORD GetUrlInfo(LPCSTR, LPCACHE_ENTRY_INFOA, LPDWORD, DWORD, DWORD);
  91. DWORD SetUrlInfo(LPCSTR, LPCACHE_ENTRY_INFOA, DWORD);
  92. DWORD FindNextEntry(HANDLE*, LPCSTR, LPCACHE_ENTRY_INFOA* ppNextCacheEntryInfo, LPDWORD, DWORD, GROUPID, DWORD, DWORD);
  93. DWORD FindNextEntry(HANDLE*, LPCSTR, LPCACHE_ENTRY_INFOA pNextCacheEntryInfo, LPDWORD, DWORD, GROUPID, DWORD);
  94. DWORD CleanupUrls(LPCTSTR szCachePath, DWORD dwFactor, DWORD dwFilter);
  95. DWORD GetUrlInGroup(LPCSTR, GROUPID*, LPDWORD);
  96. VOID SetCacheLimit(LONGLONG, DWORD);
  97. VOID GetCacheInfo(LPCSTR, LPSTR, LONGLONG*);
  98. // Methods corresponding to cache configuration APIs
  99. BOOL SetContentPath(PTSTR pszNewPath);
  100. // BOOL GetUrlCacheConfigInfo(LPCACHE_CONFIG_INFO, LPDWORD, DWORD);
  101. // BOOL SetUrlCacheConfigInfo(LPCACHE_CONFIG_INFO, DWORD);
  102. // Methods corresponding to cache group APIs
  103. DWORD CreateGroup(DWORD, GROUPID*);
  104. DWORD CreateDefaultGroups();
  105. DWORD DeleteGroup(GROUPID, DWORD);
  106. DWORD FindNextGroup(HANDLE*, DWORD, GROUPID*);
  107. DWORD GetGroupAttributes(
  108. GROUPID, DWORD, LPINTERNET_CACHE_GROUP_INFOA, LPDWORD);
  109. DWORD SetGroupAttributes(GROUPID, DWORD, LPINTERNET_CACHE_GROUP_INFOA );
  110. // notification api
  111. DWORD RegisterCacheNotify(HWND, UINT, GROUPID, DWORD);
  112. DWORD SendCacheNotification(DWORD);
  113. DWORD AddLeakFile (LPCSTR pszFile)
  114. {
  115. return _coContent->AddLeakFile (pszFile);
  116. }
  117. // allows content import to create a directory with a known name
  118. BOOL CreateContentDirWithSecureName( LPSTR szDirName)
  119. {
  120. return _coContainer[CONTENT]->CreateDirWithSecureName( szDirName);
  121. }
  122. // Creates a redirect from TargetUrl to OriginUrl
  123. BOOL CreateContentRedirect( LPSTR szTargetUrl, LPSTR szOriginUrl)
  124. {
  125. return _coContainer[CONTENT]->CreateRedirect( szTargetUrl, szOriginUrl);
  126. }
  127. VOID SetCacheSize(DWORD dwEnum, LONGLONG dlSize)
  128. {
  129. INET_ASSERT(dwEnum<NCONTAINERS);
  130. _coContainer[dwEnum]->SetCacheSize(dlSize);
  131. }
  132. VOID WalkLeakList(DWORD dwEnum)
  133. {
  134. INET_ASSERT(dwEnum<NCONTAINERS);
  135. if (_coContainer[dwEnum]->WalkLeakList())
  136. {
  137. _coContainer[dwEnum]->UnlockContainer();
  138. }
  139. }
  140. };
  141. #endif // _CONMGR_HXX