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.

85 lines
2.3 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 2000.
  5. //
  6. // File: C A C H E . H
  7. //
  8. // Contents: SSDP client cache implementation
  9. //
  10. // Notes:
  11. //
  12. // Author: mbend 12 Nov 2000
  13. //
  14. //----------------------------------------------------------------------------
  15. #pragma once
  16. #include "ulist.h"
  17. #include "upsync.h"
  18. #include "ustring.h"
  19. #include "timer.h"
  20. #include "ssdptypes.h"
  21. class CSsdpCacheEntry
  22. {
  23. public:
  24. CSsdpCacheEntry();
  25. ~CSsdpCacheEntry();
  26. // Timer callback methods
  27. void TimerFired();
  28. BOOL TimerTryToLock();
  29. void TimerUnlock();
  30. HRESULT HrInitialize(const SSDP_REQUEST * pRequest);
  31. HRESULT HrStartTimer(const SSDP_REQUEST * pRequest);
  32. BOOL FTimerFired();
  33. HRESULT HrShutdown(BOOL bExpired);
  34. HRESULT HrUpdateExpireTime(const SSDP_REQUEST * pRequest);
  35. HRESULT HrUpdateEntry(const SSDP_REQUEST * pRequest, BOOL * pbCheckListNotify);
  36. BOOL FIsMatchUSN(const char * szUSN);
  37. BOOL FIsSearchMatch(const char * szType);
  38. HRESULT HrGetRequest(SSDP_REQUEST * pRequest);
  39. void PrintItem();
  40. BOOL FCheckForDirtyInterfaceGuids(long nCount, GUID * arGuidInterfaces);
  41. private:
  42. CSsdpCacheEntry(const CSsdpCacheEntry &);
  43. CSsdpCacheEntry & operator=(const CSsdpCacheEntry &);
  44. volatile BOOL m_bTimerFired;
  45. SSDP_REQUEST m_ssdpRequest;
  46. CTimer<CSsdpCacheEntry> m_timer;
  47. CUCriticalSection m_critSec;
  48. };
  49. class CSsdpCacheEntryManager
  50. {
  51. public:
  52. ~CSsdpCacheEntryManager();
  53. static CSsdpCacheEntryManager & Instance();
  54. HRESULT HrInitialize();
  55. BOOL IsCacheListNotFull();
  56. HRESULT HrShutdown();
  57. HRESULT HrRemoveEntry(CSsdpCacheEntry * pEntry);
  58. HRESULT HrUpdateCacheList(const SSDP_REQUEST * pRequest, BOOL bIsSubscribed);
  59. HRESULT HrSearchListCache(char * szType, MessageList ** ppSvcList);
  60. HRESULT HrClearDirtyInterfaceGuids(long nCount, GUID * arGuidInterfaces);
  61. private:
  62. CSsdpCacheEntryManager();
  63. CSsdpCacheEntryManager(const CSsdpCacheEntryManager &);
  64. CSsdpCacheEntryManager & operator=(const CSsdpCacheEntryManager &);
  65. static CSsdpCacheEntryManager s_instance;
  66. typedef CUList<CSsdpCacheEntry> CacheEntryList;
  67. CUCriticalSection m_critSec;
  68. CacheEntryList m_cacheEntryList;
  69. int m_cCacheEntries;
  70. int m_cMaxCacheEntries;
  71. };