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.

223 lines
8.1 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995.
  5. //
  6. // File: tls.h
  7. //
  8. // Contents: Manage thread local storage for UrlMon.
  9. // The non-inline routines are in ..\mon\tls.cxx
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 12-02-95 JohannP (Johann Posch) Created
  15. //
  16. //----------------------------------------------------------------------------
  17. #ifndef _TLS_H_
  18. #define _TLS_H_
  19. #include "clist.hxx"
  20. #include "cookie.hxx"
  21. #include "inetdbg.h"
  22. class CTransactionMgr;
  23. class CCDLPacketMgr;
  24. class CCodeDownload;
  25. class CDownload;
  26. // notification/scheduler
  27. //+---------------------------------------------------------------------------
  28. //
  29. // forward declarations (in order to avoid type casting when accessing
  30. // data members of the SOleTlsData structure).
  31. //
  32. //+---------------------------------------------------------------------------
  33. extern DWORD gTlsIndex; // global Index for TLS
  34. //+---------------------------------------------------------------------------
  35. //
  36. // Enum: URLMKTLSFLAGS
  37. //
  38. // Synopsys: bit values for dwFlags field of SUrlMkTlsData. If you just want
  39. // to store a BOOL in TLS, use this enum and the dwFlag field.
  40. //
  41. //+---------------------------------------------------------------------------
  42. typedef enum tagURLMKTLSFLAGS
  43. {
  44. URLMKTLS_LOCALTID = 1, // whether TID is in current process or not
  45. URLMKTLS_UUIDINITIALIZED = 2, // whether logical thread was init'd
  46. URLMKTLS_INTHREADDETACH = 4, // Whether we are in thread detach. Needed
  47. // due to NT's special thread detach rules.
  48. } URLMKTLSFLAGS;
  49. //+---------------------------------------------------------------------------
  50. //
  51. // Structure: SUrlMkTlsData
  52. //
  53. // Synopsis: structure holding per thread state needed by UrlMon
  54. //
  55. //+---------------------------------------------------------------------------
  56. typedef struct tagSUrlMkTlsData
  57. {
  58. DWORD dwApartmentID; // Per thread "process ID"
  59. DWORD dwFlags; // see URLMKTLSFLAGS above
  60. HWND hwndUrlMkNotify; // notification window
  61. LONG cDispatchLevel; // dispatch nesting level
  62. CTransactionMgr *pCTransMgr; // transaction manager
  63. #ifdef PER_THREAD
  64. CMediaTypeHolder *pCMediaHolder; // media types register per apartment
  65. #endif //PER_THREAD
  66. CList<CCodeDownload *,CCodeDownload *>*
  67. pCodeDownloadList; // linked list of pointers to
  68. // CCodeDownload objects ongoing on
  69. // this thread
  70. CCookie<CDownload*> *pTrustCookie;
  71. // only the cookie owner can do
  72. // setup/winverifytrust
  73. // Others wait for the
  74. // cookie to enter these phases
  75. // Cookie availabilty is posted
  76. // as a msg. We can't uses any
  77. // regular sync apis as this
  78. // is protecting execution by the
  79. // same thread in a diff msg.
  80. CCookie<CCodeDownload*>
  81. *pSetupCookie;
  82. CCDLPacketMgr *pCDLPacketMgr; // per thread packet manager
  83. // A packet is a unit
  84. // of work that takes time eg.
  85. // trust verifcation of a piece
  86. // setup of a piece or INF
  87. // processing of one piece.
  88. // To be able to have the
  89. // client be responsive with UI
  90. // and abort capabilty we need
  91. // to split out work into as
  92. // small units as possible
  93. // and queue up these packets
  94. // Packets get run on a timer per
  95. // thread.
  96. CList<LPCWSTR ,LPCWSTR >*
  97. pRejectedFeaturesList;
  98. // linked list of pointers to
  99. // features or code downloads that
  100. // the use has explicitly rejected
  101. // on this thread
  102. #if DBG==1
  103. LONG cTraceNestingLevel; // call nesting level for UrlMonTRACE
  104. #endif
  105. #ifdef ENABLE_DEBUG
  106. DWORD ThreadId;
  107. LPDEBUG_URLMON_FUNC_RECORD Stack;
  108. int CallDepth;
  109. int IndentIncrement;
  110. DWORD StartTime;
  111. DWORD StopTime;
  112. DWORD MajorCategoryFlags;
  113. DWORD MinorCategoryFlags;
  114. #endif //ENABLE_DEBUG
  115. } SUrlMkTlsData;
  116. //+---------------------------------------------------------------------------
  117. //
  118. // class CUrlMkTls
  119. //
  120. // Synopsis: class to abstract thread-local-storage in UrlMon.
  121. //
  122. // Notes: To use Tls in UrlMon, functions should define an instance of
  123. // this class on their stack, then use the -> operator on the
  124. // instance to access fields of the SOleTls structure.
  125. //
  126. // There are two instances of the ctor. One just Assert's that
  127. // the SUrlMkTlsData has already been allocated for this thread. Most
  128. // internal code should use this ctor, since we can assert that if
  129. // the thread made it this far into our code, tls has already been
  130. // checked.
  131. //
  132. // The other ctor will check if SUrlMkTlsData exists, and attempt to
  133. // allocate and initialize it if it does not. This ctor will
  134. // return an HRESULT. Functions that are entry points to UrlMon
  135. // should use this version.
  136. //
  137. // History: 12-02-95 JohannP (Johann Posch) Created
  138. //
  139. //+---------------------------------------------------------------------------
  140. class CUrlMkTls
  141. {
  142. public:
  143. CUrlMkTls(HRESULT &hr);
  144. // to get direct access to the data structure
  145. SUrlMkTlsData * operator->(void);
  146. private:
  147. HRESULT TLSAllocData(); // allocates an SUrlMkTlsData structure
  148. SUrlMkTlsData * _pData; // ptr to UrlMon TLS data
  149. };
  150. //+---------------------------------------------------------------------------
  151. //
  152. // Method: CUrlMkTls::CUrlMkTls
  153. //
  154. // Synopsis: ctor for UrlMon Tls object.
  155. //
  156. // Notes: Peripheral UrlMon code that can not assume that some outer-layer
  157. // function has already verified the existence of the SUrlMkTlsData
  158. // structure for the current thread should use this version of
  159. // the ctor.
  160. //
  161. // History: 12-02-95 JohannP (Johann Posch) Created
  162. //
  163. //+---------------------------------------------------------------------------
  164. inline CUrlMkTls::CUrlMkTls(HRESULT &hr)
  165. {
  166. _pData = (SUrlMkTlsData *) TlsGetValue(gTlsIndex);
  167. if (_pData)
  168. hr = S_OK;
  169. else
  170. hr = TLSAllocData();
  171. }
  172. //+---------------------------------------------------------------------------
  173. //
  174. // Member: CUrlMkTls::operator->(void)
  175. //
  176. // Synopsis: returns ptr to the data structure
  177. //
  178. // History: 12-02-95 JohannP (Johann Posch) Created
  179. //
  180. //+---------------------------------------------------------------------------
  181. inline SUrlMkTlsData * CUrlMkTls::operator->(void)
  182. {
  183. return _pData;
  184. }
  185. typedef struct URLMON_TS
  186. {
  187. DWORD _dwTID;
  188. HWND _hwndNotify;
  189. URLMON_TS* _pNext;
  190. } URLMON_TS, *LPURLMON_TS;
  191. #endif // _TLS_H_