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.

252 lines
4.6 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name :
  4. childcontext.cxx
  5. Abstract:
  6. Child context implementation
  7. Author:
  8. Bilal Alam (balam) 10-Mar-2000
  9. Environment:
  10. Win32 - User Mode
  11. Project:
  12. ULW3.DLL
  13. --*/
  14. #include "precomp.hxx"
  15. ALLOC_CACHE_HANDLER * W3_CHILD_CONTEXT::sm_pachChildContexts;
  16. W3_CHILD_CONTEXT::W3_CHILD_CONTEXT(
  17. W3_MAIN_CONTEXT * pMainContext,
  18. W3_CONTEXT * pParentContext,
  19. W3_REQUEST * pRequest,
  20. BOOL fOwnRequest,
  21. W3_USER_CONTEXT * pCustomUserContext,
  22. DWORD dwExecFlags
  23. )
  24. : W3_CONTEXT( dwExecFlags ),
  25. _pMainContext( pMainContext ),
  26. _pParentContext( pParentContext ),
  27. _pRequest( pRequest ),
  28. _fOwnRequest( fOwnRequest ),
  29. _pCustomUserContext( pCustomUserContext )
  30. {
  31. //
  32. // If the parent context is disabling wildcards, custom errors, or
  33. // headers --> we should ensure those features are disabled for
  34. // this context too
  35. //
  36. DBG_ASSERT( _pParentContext != NULL );
  37. if ( !_pParentContext->QuerySendCustomError() )
  38. {
  39. _dwExecFlags |= W3_FLAG_NO_CUSTOM_ERROR;
  40. }
  41. if ( !_pParentContext->QuerySendHeaders() )
  42. {
  43. _dwExecFlags |= W3_FLAG_NO_HEADERS;
  44. }
  45. if ( !_pParentContext->QuerySendErrorBody() )
  46. {
  47. _dwExecFlags |= W3_FLAG_NO_ERROR_BODY;
  48. }
  49. //
  50. // Get the fAuthAccessCheckRequired flag from the main context so
  51. // the child conext would know if we need to do auth access check
  52. // or not.
  53. //
  54. DBG_ASSERT( _pMainContext != NULL );
  55. SetAuthAccessCheckRequired( _pMainContext->
  56. QueryAuthAccessCheckRequired() );
  57. }
  58. W3_CHILD_CONTEXT::~W3_CHILD_CONTEXT()
  59. /*++
  60. Routine Description:
  61. Deletes a child context.
  62. Arguments:
  63. None
  64. Return Value:
  65. None
  66. --*/
  67. {
  68. if ( _pUrlContext != NULL )
  69. {
  70. delete _pUrlContext;
  71. _pUrlContext = NULL;
  72. }
  73. //
  74. // Only delete the request object if we own it! (we won't own it in
  75. // case where we're doing a "reprocessurl"
  76. //
  77. if ( _pRequest )
  78. {
  79. if ( _fOwnRequest )
  80. {
  81. delete _pRequest;
  82. _pRequest = NULL;
  83. }
  84. }
  85. //
  86. // Clean up the custom user context if there is one
  87. //
  88. if ( _pCustomUserContext != NULL )
  89. {
  90. _pCustomUserContext->DereferenceUserContext();
  91. _pCustomUserContext = NULL;
  92. }
  93. }
  94. // static
  95. HRESULT
  96. W3_CHILD_CONTEXT::Initialize(
  97. VOID
  98. )
  99. /*++
  100. Routine Description:
  101. Global initialization routine for W3_CHILD_CONTEXTs
  102. Arguments:
  103. None
  104. Return Value:
  105. HRESULT
  106. --*/
  107. {
  108. ALLOC_CACHE_CONFIGURATION acConfig;
  109. HRESULT hr = NO_ERROR;
  110. //
  111. // Setup allocation lookaside
  112. //
  113. acConfig.nConcurrency = 1;
  114. acConfig.nThreshold = 100;
  115. acConfig.cbSize = sizeof( W3_CHILD_CONTEXT );
  116. DBG_ASSERT( sm_pachChildContexts == NULL );
  117. sm_pachChildContexts = new ALLOC_CACHE_HANDLER( "W3_CHILD_CONTEXT",
  118. &acConfig );
  119. if ( sm_pachChildContexts == NULL )
  120. {
  121. return HRESULT_FROM_WIN32( ERROR_NOT_ENOUGH_MEMORY );
  122. }
  123. return NO_ERROR;
  124. }
  125. // static
  126. VOID
  127. W3_CHILD_CONTEXT::Terminate(
  128. VOID
  129. )
  130. /*++
  131. Routine Description:
  132. Terminate MAIN_CONTEXT globals
  133. Arguments:
  134. None
  135. Return Value:
  136. None
  137. --*/
  138. {
  139. if ( sm_pachChildContexts != NULL )
  140. {
  141. delete sm_pachChildContexts;
  142. sm_pachChildContexts = NULL;
  143. }
  144. }
  145. HRESULT
  146. W3_CHILD_CONTEXT::RetrieveUrlContext(
  147. BOOL * pfFinished
  148. )
  149. /*++
  150. Routine Description:
  151. Retrieves URL context for this context
  152. Arguments:
  153. pfFinished - Set to TRUE if filter wants out
  154. Return Value:
  155. HRESULT
  156. --*/
  157. {
  158. URL_CONTEXT * pUrlContext;
  159. HRESULT hr;
  160. if ( pfFinished == NULL )
  161. {
  162. DBG_ASSERT( FALSE );
  163. return HRESULT_FROM_WIN32( ERROR_INVALID_PARAMETER );
  164. }
  165. *pfFinished = FALSE;
  166. QueryMainContext()->PushCurrentContext( this );
  167. hr = URL_CONTEXT::RetrieveUrlContext( this,
  168. QueryRequest(),
  169. &pUrlContext,
  170. pfFinished );
  171. QueryMainContext()->PopCurrentContext();
  172. if ( FAILED( hr ) )
  173. {
  174. return hr;
  175. }
  176. if ( *pfFinished )
  177. {
  178. return NO_ERROR;
  179. }
  180. DBG_ASSERT( pUrlContext != NULL );
  181. _pUrlContext = pUrlContext;
  182. return NO_ERROR;
  183. }