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.

101 lines
4.9 KiB

  1. // TskMgr.h : Declaration of the CTskMgr
  2. #include "resource.h" // main symbols
  3. #include "wsb.h" // Wsb structure definitions
  4. #ifndef __TSKMGR__
  5. #define __TSKMGR__
  6. #define HsmWorkQueueArrayBumpSize 10
  7. /////////////////////////////////////////////////////////////////////////////
  8. // task
  9. typedef struct _HSM_WORK_QUEUES {
  10. //
  11. // Note: First 2 fields (sessionId and pSession)
  12. // are not used for demand recall queues.
  13. //
  14. GUID sessionId; // GUID of the session
  15. CComPtr<IHsmSession> pSession; // Session interface
  16. CComPtr<IHsmWorkQueue> pWorkQueue; // WorkQueue for the session
  17. CComPtr<IHsmRecallQueue> pRecallQueue; // Demand RecallQueue
  18. HSM_WORK_QUEUE_TYPE queueType; // Type of queue
  19. HSM_WORK_QUEUE_STATE queueState; // State of the queue
  20. FILETIME birthDate; // Birth of queue
  21. } HSM_WORK_QUEUES, *PHSM_WORK_QUEUES;
  22. typedef struct {
  23. HSM_WORK_QUEUE_TYPE Type;
  24. ULONG MaxActiveAllowed;
  25. ULONG NumActive;
  26. } HSM_WORK_QUEUE_TYPE_INFO, *PHSM_WORK_QUEUE_TYPE_INFO;
  27. class CHsmTskMgr :
  28. public CComObjectRoot,
  29. public IHsmFsaTskMgr,
  30. public CComCoClass<CHsmTskMgr,&CLSID_CHsmTskMgr>
  31. {
  32. public:
  33. CHsmTskMgr() {}
  34. BEGIN_COM_MAP(CHsmTskMgr)
  35. COM_INTERFACE_ENTRY(IHsmFsaTskMgr)
  36. END_COM_MAP()
  37. DECLARE_REGISTRY_RESOURCEID( IDR_CHsmTskMgr )
  38. // IHsmFsaTskMgr
  39. public:
  40. STDMETHOD(ContactOk)( void );
  41. STDMETHOD(DoFsaWork)(IFsaPostIt *fsaWorkItem );
  42. STDMETHOD(FinalConstruct)(void);
  43. STDMETHOD(FinalRelease)(void);
  44. STDMETHOD(Init)(IUnknown *pServer);
  45. STDMETHOD(WorkQueueDone)(IHsmSession *pSession, HSM_WORK_QUEUE_TYPE type, GUID *pMediaId);
  46. private:
  47. STDMETHOD(IncreaseWorkQueueArraySize)(ULONG numToAdd);
  48. STDMETHOD(StartQueues)( void );
  49. STDMETHOD(StartFsaQueueType)(HSM_WORK_QUEUE_TYPE type);
  50. STDMETHOD(FindOldestQueue)(HSM_WORK_QUEUE_TYPE type, ULONG *pIndex);
  51. STDMETHOD(EnsureQueueForFsaSession)(IHsmSession *pSession, FSA_REQUEST_ACTION fsaAction, IHsmWorkQueue **ppWorkQueue, BOOL *bCreated);
  52. STDMETHOD(AddToRecallQueueForFsaSession)(IHsmSession *pSession, IHsmRecallQueue **ppWorkQueue, BOOL *bCreated, GUID *pMediaId, GUID *pBagId, LONGLONG dataSetStart, IFsaPostIt *pFsaWorkItem);
  53. STDMETHOD(AddWorkQueueElement)(IHsmSession *pSession, HSM_WORK_QUEUE_TYPE type, ULONG *pIndex);
  54. STDMETHOD(FindWorkQueueElement)(IHsmSession *pSession, HSM_WORK_QUEUE_TYPE type, ULONG *pIndex, GUID *pMediaId);
  55. STDMETHOD(FindRecallQueueElement(IN IHsmSession *pSession, IN GUID *pMediaId, OUT IHsmRecallQueue **ppWorkQueue, OUT BOOL *bCreated));
  56. STDMETHOD(GetWorkQueueElement)(ULONG index, IHsmSession **ppSession, IHsmWorkQueue **ppWorkQueue, HSM_WORK_QUEUE_TYPE *pType, HSM_WORK_QUEUE_STATE *pState, FILETIME *pBirthDate);
  57. STDMETHOD(SetWorkQueueElement)(ULONG index, IHsmSession *pSession, IHsmWorkQueue *pWorkQueue, HSM_WORK_QUEUE_TYPE type, HSM_WORK_QUEUE_STATE state, FILETIME birthdate);
  58. STDMETHOD(GetRecallQueueElement)(ULONG index, IHsmRecallQueue **ppWorkQueue, HSM_WORK_QUEUE_STATE *pState, FILETIME *pBirthDate);
  59. STDMETHOD(SetRecallQueueElement)(ULONG index, IHsmRecallQueue *pWorkQueue, HSM_WORK_QUEUE_TYPE queueType, HSM_WORK_QUEUE_STATE state, FILETIME birthdate);
  60. STDMETHOD(RemoveWorkQueueElement)(ULONG index);
  61. STDMETHOD(FindRecallMediaToUse)(IN IFsaPostIt *pFsaWorkItem, OUT GUID *pMediaToUse, OUT GUID *pBagId, OUT LONGLONG *pDataSetStart);
  62. // IHsmSystemState
  63. STDMETHOD( ChangeSysState )( HSM_SYSTEM_STATE* pSysState );
  64. // We want the next two pointers (to the Hsm Server) to be weak
  65. // references and **not** add ref the server. This is so shutting
  66. // down the server really works.
  67. // CComPtr<IHsmServer> m_pServer; // Server owning TskMgr
  68. // CComPtr<IWsbCreateLocalObject> m_pHsmServerCreate; // Server object creater
  69. IHsmServer *m_pServer; // Server owning TskMgr
  70. IWsbCreateLocalObject *m_pHsmServerCreate; // Server object creater
  71. PHSM_WORK_QUEUES m_pWorkQueues; // Work delegated by TskMgr
  72. ULONG m_NumWorkQueues; // Number of work queues
  73. CRITICAL_SECTION m_WorkQueueLock; // Protect array access and update
  74. // from multiple thread access
  75. CRITICAL_SECTION m_CurrentRunningLock; // Protect starting queues
  76. // from multiple thread access
  77. CRITICAL_SECTION m_CreateWorkQueueLock; // Protect creating queues
  78. // from multiple thread access
  79. PHSM_WORK_QUEUE_TYPE_INFO m_pWorkQueueTypeInfo; // Info about work queue types
  80. ULONG m_nWorkQueueTypes; // Number of work queue types
  81. };
  82. #endif