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.

198 lines
4.6 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1997.
  5. //
  6. // File: cibackup.hxx
  7. //
  8. // Contents: Content Index index migration
  9. //
  10. // Classes: CBackupCiWorkItem
  11. //
  12. // History: 3-17-97 srikants Created
  13. //
  14. //----------------------------------------------------------------------------
  15. #pragma once
  16. #include <psavtrak.hxx>
  17. #include "indsnap.hxx"
  18. class CResManager;
  19. class PStorage;
  20. class CPartition;
  21. class CFresh;
  22. //+---------------------------------------------------------------------------
  23. //
  24. // Class: CBackupCiWorkItem
  25. //
  26. // Purpose: A work item that backups the Content Index persistent data.
  27. // This work item will be created by the caller and the merge
  28. // thread will process the work item.
  29. //
  30. // History: 3-18-97 srikants Created
  31. //
  32. //----------------------------------------------------------------------------
  33. class CBackupCiWorkItem : INHERIT_UNWIND
  34. {
  35. INLINE_UNWIND( CBackupCiWorkItem )
  36. public:
  37. enum EBackupState
  38. {
  39. eNotStarted,
  40. eDoingMerge, // Can enter here only from eNotStarted
  41. eDoingBackup, // Can enter here only from eDoingMerge
  42. eDone // This is a final state.
  43. };
  44. CBackupCiWorkItem( PStorage & storage,
  45. BOOL fFull,
  46. PSaveProgressTracker & progressTracker );
  47. void LokSetStatus( NTSTATUS status )
  48. {
  49. _status = status;
  50. }
  51. NTSTATUS GetStatus() const { return _status; }
  52. void LokSetDone()
  53. {
  54. _backupState= eDone;
  55. _evtDone.Set();
  56. }
  57. void LokSetDoingMerge()
  58. {
  59. if ( _backupState == eNotStarted )
  60. {
  61. _backupState = eDoingMerge;
  62. }
  63. else
  64. {
  65. ciDebugOut(( DEB_WARN, "LokSetDoingMerge() cannot be set\n" ));
  66. }
  67. }
  68. void LokSetDoingBackup()
  69. {
  70. if ( _backupState == eDoingMerge )
  71. {
  72. _backupState = eDoingBackup;
  73. }
  74. else
  75. {
  76. ciDebugOut(( DEB_WARN, "LokSetDoingBackup() cannot be set\n" ));
  77. }
  78. }
  79. BOOL LokIsDone() const
  80. {
  81. return eDone == _backupState;
  82. }
  83. BOOL LokIsDoingMerge() const
  84. {
  85. return eDoingMerge == _backupState;
  86. }
  87. void LokReset()
  88. {
  89. _evtDone.Reset();
  90. }
  91. void WaitForCompletion( DWORD dwWaitTime = INFINITE )
  92. {
  93. _evtDone.Wait( dwWaitTime );
  94. }
  95. PStorage & GetStorage() { return _storage; }
  96. BOOL IsFullSave() const { return _fFull || _fDoingFull; }
  97. PSaveProgressTracker & GetSaveProgressTracker()
  98. {
  99. return _progressTracker;
  100. }
  101. ICiEnumWorkids * AcquireWorkIdEnum()
  102. {
  103. return _xEnumWorkids.Acquire();
  104. }
  105. void SetDoingFullSave() { _fDoingFull = TRUE; }
  106. XInterface<ICiEnumWorkids> & GetWorkidsIf()
  107. {
  108. return _xEnumWorkids;
  109. }
  110. void LokUpdateMergeProgress( ULONG ulNum, ULONG ulDenom )
  111. {
  112. _progressTracker.UpdateMergeProgress( ulNum, ulDenom );
  113. }
  114. private:
  115. NTSTATUS _status; // Status of the operation.
  116. PStorage & _storage; // Destination storage object.
  117. const BOOL _fFull; // Set to TRUE if a full save is needed
  118. PSaveProgressTracker & _progressTracker; // Progress tracker.
  119. CEventSem _evtDone; // Event set when the operation is done.
  120. BOOL _fDoingFull; // Set to TRUE if a full save is being done
  121. XInterface<ICiEnumWorkids> _xEnumWorkids;
  122. EBackupState _backupState;
  123. };
  124. //+---------------------------------------------------------------------------
  125. //
  126. // Class: CBackupCiPersData
  127. //
  128. // Purpose: The object that does the actual work of backing up the
  129. // indexes and relevant data.
  130. //
  131. // History: 3-18-97 srikants Created
  132. //
  133. //----------------------------------------------------------------------------
  134. class CBackupCiPersData : INHERIT_UNWIND
  135. {
  136. INLINE_UNWIND( CBackupCiPersData )
  137. public:
  138. CBackupCiPersData( CBackupCiWorkItem & workItem,
  139. CResManager & resman,
  140. CPartition & partn );
  141. ~CBackupCiPersData();
  142. void LokGrabResources();
  143. void BackupIndexes();
  144. void LokBackupMetaInfo();
  145. private:
  146. CBackupCiWorkItem & _workItem;
  147. CIndexSnapshot * _pIndSnap;
  148. CResManager & _resman;
  149. CPartition & _partn;
  150. PIndexTable & _indexTable;
  151. CFresh & _fresh;
  152. };