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.

193 lines
3.7 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. Async.hxx
  5. Abstract:
  6. Declaration of CVssAsyncBackup
  7. brian berkowitz [brianb] 05/10/2000
  8. TBD:
  9. Add comments.
  10. Revision History:
  11. Name Date Comments
  12. brianb 04/10/2000 Created
  13. --*/
  14. #ifndef __ASYNC_HXX__
  15. #define __ASYNC_HXX__
  16. #if _MSC_VER > 1000
  17. #pragma once
  18. #endif
  19. ////////////////////////////////////////////////////////////////////////
  20. // Standard foo for file name aliasing. This code block must be after
  21. // all includes of VSS header files.
  22. //
  23. #ifdef VSS_FILE_ALIAS
  24. #undef VSS_FILE_ALIAS
  25. #endif
  26. #define VSS_FILE_ALIAS "BUEASYNH"
  27. //
  28. ////////////////////////////////////////////////////////////////////////
  29. class CVssBackupComponents;
  30. /////////////////////////////////////////////////////////////////////////////
  31. // CVssAsyncBackup
  32. class ATL_NO_VTABLE CVssAsyncBackup :
  33. public CComObjectRoot,
  34. public IVssAsync,
  35. protected CVssWorkerThread
  36. {
  37. // Constructors& destructors
  38. protected:
  39. CVssAsyncBackup();
  40. ~CVssAsyncBackup();
  41. public:
  42. CVssAsyncBackup(CVssAsyncBackup &);
  43. enum VSS_ASYNC_STATE
  44. {
  45. VSS_AS_UNDEFINED,
  46. VSS_AS_PREPARE_FOR_BACKUP,
  47. VSS_AS_BACKUP_COMPLETE,
  48. VSS_AS_RESTORE,
  49. VSS_AS_GATHER_WRITER_METADATA,
  50. VSS_AS_GATHER_WRITER_STATUS
  51. };
  52. static IVssAsync* CreateInstanceAndStartJob(
  53. IN CVssBackupComponents* pBackupComponents,
  54. IN VSS_ASYNC_STATE state
  55. ) throw(HRESULT);
  56. // ATL stuff
  57. public:
  58. BEGIN_COM_MAP( CVssAsyncBackup )
  59. COM_INTERFACE_ENTRY( IVssAsync )
  60. END_COM_MAP()
  61. // IVssAsync interface
  62. public:
  63. STDMETHOD(Cancel)();
  64. STDMETHOD(Wait)(DWORD dwMilliseconds = INFINITE);
  65. STDMETHOD(QueryStatus)(
  66. OUT HRESULT* pHrResult,
  67. OUT INT* pnPercentDone
  68. );
  69. void SetOwned()
  70. {
  71. m_bOwned = true;
  72. }
  73. void ClearOwned()
  74. {
  75. m_bOwned = false;
  76. }
  77. // CVssWorkerThread overrides
  78. protected:
  79. bool OnInit();
  80. void OnRun();
  81. void OnFinish();
  82. void OnTerminate();
  83. // Data members
  84. protected:
  85. // Critical section or avoiding race between tasks
  86. CVssSafeCriticalSection m_cs;
  87. // is critical section initialized
  88. bool m_bcsInitialized;
  89. // Snapshot Set object.
  90. CVssBackupComponents *m_pBackupComponents;
  91. // hold on to backup components object for lifetime of async object
  92. CComPtr<IVssBackupComponents> m_pvbcReference;
  93. HRESULT m_hrState; // Set to inform the clients about the result.
  94. // state
  95. VSS_ASYNC_STATE m_state;
  96. // used for GatherWriterStatus and GatherWriterMetadata
  97. VSS_BACKUPCALL_STATE m_stateSaved;
  98. UINT m_timestamp;
  99. // whether async interface is owned by called thread
  100. bool m_bOwned;
  101. };
  102. /////////////////////////////////////////////////////////////////////////////
  103. // CVssAsyncBackup
  104. class ATL_NO_VTABLE CVssAsyncCover :
  105. public CComObjectRoot,
  106. public IVssAsync
  107. {
  108. // Constructors& destructors
  109. protected:
  110. CVssAsyncCover(): m_pvbc(NULL) {};
  111. CVssAsyncCover(const CVssAsyncCover&);
  112. public:
  113. static void CreateInstance(
  114. IN CVssBackupComponents* pBackupComponents,
  115. IN IVssAsync* pAsyncInternal,
  116. OUT IVssAsync** ppAsync
  117. ) throw(HRESULT);
  118. // ATL stuff
  119. public:
  120. BEGIN_COM_MAP( CVssAsyncBackup )
  121. COM_INTERFACE_ENTRY( IVssAsync )
  122. END_COM_MAP()
  123. // IVssAsync interface
  124. public:
  125. STDMETHOD(Cancel)();
  126. STDMETHOD(Wait)(DWORD dwMilliseconds = INFINITE);
  127. STDMETHOD(QueryStatus)
  128. (
  129. OUT HRESULT* pHrResult,
  130. OUT INT* pnPercentDone
  131. );
  132. CComPtr<IVssAsync> m_pAsync;
  133. CComPtr<IVssBackupComponents> m_pvbcReference; // Only for keeping the reference count.
  134. CVssBackupComponents* m_pvbc;
  135. };
  136. #endif // __ASYNC_HXX__