/work/obj-fuzz/dist/include/mozilla/net/HttpChannelChild.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set sw=2 ts=8 et tw=80 : */ |
3 | | |
4 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
5 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
6 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
7 | | |
8 | | #ifndef mozilla_net_HttpChannelChild_h |
9 | | #define mozilla_net_HttpChannelChild_h |
10 | | |
11 | | #include "mozilla/Mutex.h" |
12 | | #include "mozilla/Telemetry.h" |
13 | | #include "mozilla/UniquePtr.h" |
14 | | #include "mozilla/net/HttpBaseChannel.h" |
15 | | #include "mozilla/net/NeckoTargetHolder.h" |
16 | | #include "mozilla/net/PHttpChannelChild.h" |
17 | | #include "mozilla/net/ChannelEventQueue.h" |
18 | | |
19 | | #include "nsIStreamListener.h" |
20 | | #include "nsILoadGroup.h" |
21 | | #include "nsIInterfaceRequestor.h" |
22 | | #include "nsIInterfaceRequestorUtils.h" |
23 | | #include "nsIProgressEventSink.h" |
24 | | #include "nsICacheInfoChannel.h" |
25 | | #include "nsIApplicationCache.h" |
26 | | #include "nsIApplicationCacheChannel.h" |
27 | | #include "nsIUploadChannel2.h" |
28 | | #include "nsIResumableChannel.h" |
29 | | #include "nsIProxiedChannel.h" |
30 | | #include "nsIAsyncVerifyRedirectCallback.h" |
31 | | #include "nsIChildChannel.h" |
32 | | #include "nsIHttpChannelChild.h" |
33 | | #include "nsIDivertableChannel.h" |
34 | | #include "nsIThreadRetargetableRequest.h" |
35 | | #include "mozilla/net/DNS.h" |
36 | | |
37 | | using mozilla::Telemetry::LABELS_HTTP_CHILD_OMT_STATS; |
38 | | |
39 | | class nsIEventTarget; |
40 | | class nsInputStreamPump; |
41 | | class nsIInterceptedBodyCallback; |
42 | | |
43 | | #define HTTP_CHANNEL_CHILD_IID \ |
44 | | { 0x321bd99e, 0x2242, 0x4dc6, \ |
45 | | { 0xbb, 0xec, 0xd5, 0x06, 0x29, 0x7c, 0x39, 0x83 } } |
46 | | |
47 | | namespace mozilla { |
48 | | namespace net { |
49 | | |
50 | | class HttpBackgroundChannelChild; |
51 | | class InterceptedChannelContent; |
52 | | class InterceptStreamListener; |
53 | | class SyntheticDiversionListener; |
54 | | |
55 | | class HttpChannelChild final : public PHttpChannelChild |
56 | | , public HttpBaseChannel |
57 | | , public HttpAsyncAborter<HttpChannelChild> |
58 | | , public nsICacheInfoChannel |
59 | | , public nsIProxiedChannel |
60 | | , public nsIApplicationCacheChannel |
61 | | , public nsIAsyncVerifyRedirectCallback |
62 | | , public nsIChildChannel |
63 | | , public nsIHttpChannelChild |
64 | | , public nsIDivertableChannel |
65 | | , public nsIThreadRetargetableRequest |
66 | | , public NeckoTargetHolder |
67 | | { |
68 | | virtual ~HttpChannelChild(); |
69 | | public: |
70 | | NS_DECL_ISUPPORTS_INHERITED |
71 | | NS_DECL_NSICACHEINFOCHANNEL |
72 | | NS_DECL_NSIPROXIEDCHANNEL |
73 | | NS_DECL_NSIAPPLICATIONCACHECONTAINER |
74 | | NS_DECL_NSIAPPLICATIONCACHECHANNEL |
75 | | NS_DECL_NSIASYNCVERIFYREDIRECTCALLBACK |
76 | | NS_DECL_NSICHILDCHANNEL |
77 | | NS_DECL_NSIHTTPCHANNELCHILD |
78 | | NS_DECL_NSIDIVERTABLECHANNEL |
79 | | NS_DECL_NSITHREADRETARGETABLEREQUEST |
80 | | NS_DECLARE_STATIC_IID_ACCESSOR(HTTP_CHANNEL_CHILD_IID) |
81 | | |
82 | | HttpChannelChild(); |
83 | | |
84 | | // Methods HttpBaseChannel didn't implement for us or that we override. |
85 | | // |
86 | | // nsIRequest |
87 | | NS_IMETHOD Cancel(nsresult status) override; |
88 | | NS_IMETHOD Suspend() override; |
89 | | NS_IMETHOD Resume() override; |
90 | | // nsIChannel |
91 | | NS_IMETHOD GetSecurityInfo(nsISupports **aSecurityInfo) override; |
92 | | NS_IMETHOD AsyncOpen(nsIStreamListener *listener, nsISupports *aContext) override; |
93 | | NS_IMETHOD AsyncOpen2(nsIStreamListener *aListener) override; |
94 | | |
95 | | // HttpBaseChannel::nsIHttpChannel |
96 | | NS_IMETHOD SetReferrerWithPolicy(nsIURI *referrer, uint32_t referrerPolicy) override; |
97 | | NS_IMETHOD SetRequestHeader(const nsACString& aHeader, |
98 | | const nsACString& aValue, |
99 | | bool aMerge) override; |
100 | | NS_IMETHOD SetEmptyRequestHeader(const nsACString& aHeader) override; |
101 | | NS_IMETHOD RedirectTo(nsIURI *newURI) override; |
102 | | NS_IMETHOD UpgradeToSecure() override; |
103 | | NS_IMETHOD GetProtocolVersion(nsACString& aProtocolVersion) override; |
104 | | // nsIHttpChannelInternal |
105 | | NS_IMETHOD SetupFallbackChannel(const char *aFallbackKey) override; |
106 | | // nsISupportsPriority |
107 | | NS_IMETHOD SetPriority(int32_t value) override; |
108 | | // nsIClassOfService |
109 | | NS_IMETHOD SetClassFlags(uint32_t inFlags) override; |
110 | | NS_IMETHOD AddClassFlags(uint32_t inFlags) override; |
111 | | NS_IMETHOD ClearClassFlags(uint32_t inFlags) override; |
112 | | // nsIResumableChannel |
113 | | NS_IMETHOD ResumeAt(uint64_t startPos, const nsACString& entityID) override; |
114 | | |
115 | | // IPDL holds a reference while the PHttpChannel protocol is live (starting at |
116 | | // AsyncOpen, and ending at either OnStopRequest or any IPDL error, either of |
117 | | // which call NeckoChild::DeallocPHttpChannelChild()). |
118 | | void AddIPDLReference(); |
119 | | void ReleaseIPDLReference(); |
120 | | |
121 | | MOZ_MUST_USE bool IsSuspended(); |
122 | | |
123 | | void FlushedForDiversion(); |
124 | | |
125 | | void OnCopyComplete(nsresult aStatus) override; |
126 | | |
127 | | // Callback while background channel is ready. |
128 | | void OnBackgroundChildReady(HttpBackgroundChannelChild* aBgChild); |
129 | | // Callback while background channel is destroyed. |
130 | | void OnBackgroundChildDestroyed(HttpBackgroundChannelChild* aBgChild); |
131 | | |
132 | | nsresult CrossProcessRedirectFinished(nsresult aStatus); |
133 | | |
134 | | protected: |
135 | | mozilla::ipc::IPCResult RecvOnStartRequest(const nsresult& channelStatus, |
136 | | const nsHttpResponseHead& responseHead, |
137 | | const bool& useResponseHead, |
138 | | const nsHttpHeaderArray& requestHeaders, |
139 | | const ParentLoadInfoForwarderArgs& loadInfoForwarder, |
140 | | const bool& isFromCache, |
141 | | const bool& cacheEntryAvailable, |
142 | | const uint64_t& cacheEntryId, |
143 | | const int32_t& cacheFetchCount, |
144 | | const uint32_t& cacheExpirationTime, |
145 | | const nsCString& cachedCharset, |
146 | | const nsCString& securityInfoSerialization, |
147 | | const NetAddr& selfAddr, |
148 | | const NetAddr& peerAddr, |
149 | | const int16_t& redirectCount, |
150 | | const uint32_t& cacheKey, |
151 | | const nsCString& altDataType, |
152 | | const int64_t& altDataLen, |
153 | | const bool& aApplyConversion, |
154 | | const ResourceTimingStruct& aTiming) override; |
155 | | mozilla::ipc::IPCResult RecvFailedAsyncOpen(const nsresult& status) override; |
156 | | mozilla::ipc::IPCResult RecvRedirect1Begin(const uint32_t& registrarId, |
157 | | const URIParams& newURI, |
158 | | const uint32_t& newLoadFlags, |
159 | | const uint32_t& redirectFlags, |
160 | | const ParentLoadInfoForwarderArgs& loadInfoForwarder, |
161 | | const nsHttpResponseHead& responseHead, |
162 | | const nsCString& securityInfoSerialization, |
163 | | const uint64_t& channelId, |
164 | | const NetAddr& oldPeerAddr) override; |
165 | | mozilla::ipc::IPCResult RecvRedirect3Complete() override; |
166 | | mozilla::ipc::IPCResult RecvAssociateApplicationCache(const nsCString& groupID, |
167 | | const nsCString& clientID) override; |
168 | | mozilla::ipc::IPCResult RecvDeleteSelf() override; |
169 | | mozilla::ipc::IPCResult RecvFinishInterceptedRedirect() override; |
170 | | |
171 | | mozilla::ipc::IPCResult RecvReportSecurityMessage(const nsString& messageTag, |
172 | | const nsString& messageCategory) override; |
173 | | |
174 | | mozilla::ipc::IPCResult RecvIssueDeprecationWarning(const uint32_t& warning, |
175 | | const bool& asError) override; |
176 | | |
177 | | mozilla::ipc::IPCResult RecvSetPriority(const int16_t& aPriority) override; |
178 | | |
179 | | mozilla::ipc::IPCResult RecvAttachStreamFilter(Endpoint<extensions::PStreamFilterParent>&& aEndpoint) override; |
180 | | |
181 | | mozilla::ipc::IPCResult RecvCancelDiversion() override; |
182 | | |
183 | | mozilla::ipc::IPCResult RecvCancelRedirected() override; |
184 | | |
185 | | virtual void ActorDestroy(ActorDestroyReason aWhy) override; |
186 | | |
187 | | virtual void DoNotifyListenerCleanup() override; |
188 | | |
189 | | virtual void DoAsyncAbort(nsresult aStatus) override; |
190 | | |
191 | | nsresult |
192 | | AsyncCall(void (HttpChannelChild::*funcPtr)(), |
193 | 0 | nsRunnableMethod<HttpChannelChild> **retval = nullptr) override { |
194 | 0 | // Normally, this method would just be implemented directly, but clang |
195 | 0 | // miscompiles the corresponding non-virtual thunk on linux x86. |
196 | 0 | // It however doesn't when going though a non-virtual method. |
197 | 0 | // https://bugs.llvm.org/show_bug.cgi?id=38466 |
198 | 0 | return AsyncCallImpl(funcPtr, retval); |
199 | 0 | }; |
200 | | |
201 | | // Get event target for processing network events. |
202 | | already_AddRefed<nsIEventTarget> GetNeckoTarget() override; |
203 | | |
204 | | virtual mozilla::ipc::IPCResult RecvLogBlockedCORSRequest(const nsString& aMessage, const nsCString& aCategory) override; |
205 | | NS_IMETHOD LogBlockedCORSRequest(const nsAString & aMessage, const nsACString& aCategory) override; |
206 | | |
207 | | private: |
208 | | nsresult |
209 | | AsyncCallImpl(void (HttpChannelChild::*funcPtr)(), |
210 | | nsRunnableMethod<HttpChannelChild> **retval); |
211 | | |
212 | | class OverrideRunnable : public Runnable { |
213 | | public: |
214 | | OverrideRunnable(HttpChannelChild* aChannel, |
215 | | HttpChannelChild* aNewChannel, |
216 | | InterceptStreamListener* aListener, |
217 | | nsIInputStream* aInput, |
218 | | nsIInterceptedBodyCallback* aCallback, |
219 | | nsAutoPtr<nsHttpResponseHead>& aHead, |
220 | | nsICacheInfoChannel* aCacheInfo); |
221 | | |
222 | | NS_IMETHOD Run() override; |
223 | | void OverrideWithSynthesizedResponse(); |
224 | | private: |
225 | | RefPtr<HttpChannelChild> mChannel; |
226 | | RefPtr<HttpChannelChild> mNewChannel; |
227 | | RefPtr<InterceptStreamListener> mListener; |
228 | | nsCOMPtr<nsIInputStream> mInput; |
229 | | nsCOMPtr<nsIInterceptedBodyCallback> mCallback; |
230 | | nsAutoPtr<nsHttpResponseHead> mHead; |
231 | | nsCOMPtr<nsICacheInfoChannel> mSynthesizedCacheInfo; |
232 | | }; |
233 | | |
234 | | // Sets the event target for future IPC messages. Messages will either be |
235 | | // directed to the TabGroup or DocGroup, depending on the LoadInfo associated |
236 | | // with the channel. Should be called when a new channel is being set up, |
237 | | // before the constructor message is sent to the parent. |
238 | | void SetEventTarget(); |
239 | | |
240 | | // Get event target for ODA. |
241 | | already_AddRefed<nsIEventTarget> GetODATarget(); |
242 | | |
243 | | MOZ_MUST_USE nsresult ContinueAsyncOpen(); |
244 | | |
245 | | // Callbacks while receiving OnTransportAndData/OnStopRequest/OnProgress/ |
246 | | // OnStatus/FlushedForDiversion/DivertMessages on background IPC channel. |
247 | | void ProcessOnTransportAndData(const nsresult& aChannelStatus, |
248 | | const nsresult& aStatus, |
249 | | const uint64_t& aOffset, |
250 | | const uint32_t& aCount, |
251 | | const nsCString& aData); |
252 | | void ProcessOnStopRequest(const nsresult& aStatusCode, |
253 | | const ResourceTimingStruct& aTiming, |
254 | | const nsHttpHeaderArray& aResponseTrailers); |
255 | | void ProcessOnProgress(const int64_t& aProgress, const int64_t& aProgressMax); |
256 | | void ProcessOnStatus(const nsresult& aStatus); |
257 | | void ProcessFlushedForDiversion(); |
258 | | void ProcessDivertMessages(); |
259 | | void ProcessNotifyTrackingProtectionDisabled(); |
260 | | void ProcessNotifyTrackingCookieBlocked(uint32_t aRejectedReason); |
261 | | void ProcessNotifyTrackingResource(bool aIsThirdParty); |
262 | | void ProcessSetClassifierMatchedInfo(const nsCString& aList, |
263 | | const nsCString& aProvider, |
264 | | const nsCString& aFullHash); |
265 | | |
266 | | // Return true if we need to tell the parent the size of unreported received |
267 | | // data |
268 | | bool NeedToReportBytesRead(); |
269 | | int32_t mUnreportBytesRead = 0; |
270 | | |
271 | | void DoOnStartRequest(nsIRequest* aRequest, nsISupports* aContext); |
272 | | void DoOnStatus(nsIRequest* aRequest, nsresult status); |
273 | | void DoOnProgress(nsIRequest* aRequest, int64_t progress, int64_t progressMax); |
274 | | void DoOnDataAvailable(nsIRequest* aRequest, nsISupports* aContext, nsIInputStream* aStream, |
275 | | uint64_t offset, uint32_t count); |
276 | | void DoPreOnStopRequest(nsresult aStatus); |
277 | | void DoOnStopRequest(nsIRequest* aRequest, nsresult aChannelStatus, nsISupports* aContext); |
278 | | |
279 | | bool ShouldInterceptURI(nsIURI* aURI, bool& aShouldUpgrade); |
280 | | |
281 | | // Discard the prior interception and continue with the original network request. |
282 | | void ResetInterception(); |
283 | | |
284 | | // Override this channel's pending response with a synthesized one. The content will be |
285 | | // asynchronously read from the pump. |
286 | | void OverrideWithSynthesizedResponse(nsAutoPtr<nsHttpResponseHead>& aResponseHead, |
287 | | nsIInputStream* aSynthesizedInput, |
288 | | nsIInterceptedBodyCallback* aSynthesizedCallback, |
289 | | InterceptStreamListener* aStreamListener, |
290 | | nsICacheInfoChannel* aCacheInfoChannel); |
291 | | |
292 | | void ForceIntercepted(nsIInputStream* aSynthesizedInput, |
293 | | nsIInterceptedBodyCallback* aSynthesizedCallback, |
294 | | nsICacheInfoChannel* aCacheInfo); |
295 | | |
296 | | // Try send DeletingChannel message to parent side. Dispatch an async task to |
297 | | // main thread if invoking on non-main thread. |
298 | | void TrySendDeletingChannel(); |
299 | | |
300 | | // Try invoke Cancel if on main thread, or prepend a CancelEvent in mEventQ to |
301 | | // ensure Cacnel is processed before any other channel events. |
302 | | void CancelOnMainThread(nsresult aRv); |
303 | | |
304 | | void |
305 | | MaybeCallSynthesizedCallback(); |
306 | | |
307 | | private: |
308 | | // this section is for main-thread-only object |
309 | | // all the references need to be proxy released on main thread. |
310 | | nsCOMPtr<nsIChildChannel> mRedirectChannelChild; |
311 | | RefPtr<InterceptStreamListener> mInterceptListener; |
312 | | // Needed to call AsyncOpen in FinishInterceptedRedirect |
313 | | nsCOMPtr<nsIStreamListener> mInterceptedRedirectListener; |
314 | | nsCOMPtr<nsISupports> mInterceptedRedirectContext; |
315 | | |
316 | | // Proxy release all members above on main thread. |
317 | | void ReleaseMainThreadOnlyReferences(); |
318 | | |
319 | | private: |
320 | | nsCString mCachedCharset; |
321 | | nsCString mProtocolVersion; |
322 | | |
323 | | RequestHeaderTuples mClientSetRequestHeaders; |
324 | | RefPtr<nsInputStreamPump> mSynthesizedResponsePump; |
325 | | nsCOMPtr<nsIInputStream> mSynthesizedInput; |
326 | | nsCOMPtr<nsIInterceptedBodyCallback> mSynthesizedCallback; |
327 | | nsCOMPtr<nsICacheInfoChannel> mSynthesizedCacheInfo; |
328 | | RefPtr<ChannelEventQueue> mEventQ; |
329 | | |
330 | | // Used to ensure atomicity of mBgChild and mBgInitFailCallback |
331 | | Mutex mBgChildMutex; |
332 | | |
333 | | // Associated HTTP background channel |
334 | | RefPtr<HttpBackgroundChannelChild> mBgChild; |
335 | | |
336 | | // Error handling procedure if failed to establish PBackground IPC |
337 | | nsCOMPtr<nsIRunnable> mBgInitFailCallback; |
338 | | |
339 | | // Remove the association with background channel after OnStopRequest |
340 | | // or AsyncAbort. |
341 | | void CleanupBackgroundChannel(); |
342 | | |
343 | | // Needed to call CleanupRedirectingChannel in FinishInterceptedRedirect |
344 | | RefPtr<HttpChannelChild> mInterceptingChannel; |
345 | | // Used to call OverrideWithSynthesizedResponse in FinishInterceptedRedirect |
346 | | RefPtr<OverrideRunnable> mOverrideRunnable; |
347 | | |
348 | | // Target thread for delivering ODA. |
349 | | nsCOMPtr<nsIEventTarget> mODATarget; |
350 | | // Used to ensure atomicity of mNeckoTarget / mODATarget; |
351 | | Mutex mEventTargetMutex; |
352 | | |
353 | | // If nsUnknownDecoder is involved OnStartRequest call will be delayed and |
354 | | // this queue keeps OnDataAvailable data until OnStartRequest is finally |
355 | | // called. |
356 | | nsTArray<UniquePtr<ChannelEvent>> mUnknownDecoderEventQ; |
357 | | |
358 | | TimeStamp mLastStatusReported; |
359 | | |
360 | | int64_t mSynthesizedStreamLength; |
361 | | uint64_t mCacheEntryId; |
362 | | |
363 | | // The result of RetargetDeliveryTo for this channel. |
364 | | // |notRequested| represents OMT is not requested by the channel owner. |
365 | | LABELS_HTTP_CHILD_OMT_STATS mOMTResult = LABELS_HTTP_CHILD_OMT_STATS::notRequested; |
366 | | |
367 | | uint32_t mCacheKey; |
368 | | int32_t mCacheFetchCount; |
369 | | uint32_t mCacheExpirationTime; |
370 | | |
371 | | // To ensure only one SendDeletingChannel is triggered. |
372 | | Atomic<bool> mDeletingChannelSent; |
373 | | |
374 | | Atomic<bool> mIPCOpen; |
375 | | |
376 | | Atomic<bool, ReleaseAcquire> mUnknownDecoderInvolved; |
377 | | |
378 | | // Once set, OnData and possibly OnStop will be diverted to the parent. |
379 | | Atomic<bool, ReleaseAcquire> mDivertingToParent; |
380 | | // Once set, no OnStart/OnData/OnStop callbacks should be received from the |
381 | | // parent channel, nor dequeued from the ChannelEventQueue. |
382 | | Atomic<bool, ReleaseAcquire> mFlushedForDiversion; |
383 | | |
384 | | uint8_t mIsFromCache : 1; |
385 | | uint8_t mCacheEntryAvailable : 1; |
386 | | uint8_t mAltDataCacheEntryAvailable : 1; |
387 | | |
388 | | // If ResumeAt is called before AsyncOpen, we need to send extra data upstream |
389 | | uint8_t mSendResumeAt : 1; |
390 | | |
391 | | uint8_t mKeptAlive : 1; // IPC kept open, but only for security info |
392 | | |
393 | | // Set if SendSuspend is called. Determines if SendResume is needed when |
394 | | // diverting callbacks to parent. |
395 | | uint8_t mSuspendSent : 1; |
396 | | |
397 | | // Set if a response was synthesized, indicating that any forthcoming redirects |
398 | | // should be intercepted. |
399 | | uint8_t mSynthesizedResponse : 1; |
400 | | |
401 | | // Set if a synthesized response should cause us to explictly allows intercepting |
402 | | // an expected forthcoming redirect. |
403 | | uint8_t mShouldInterceptSubsequentRedirect : 1; |
404 | | // Set if a redirection is being initiated to facilitate providing a synthesized |
405 | | // response to a channel using a different principal than the current one. |
406 | | uint8_t mRedirectingForSubsequentSynthesizedResponse : 1; |
407 | | |
408 | | // Set if a manual redirect mode channel needs to be intercepted in the |
409 | | // parent. |
410 | | uint8_t mPostRedirectChannelShouldIntercept : 1; |
411 | | // Set if a manual redirect mode channel needs to be upgraded to a secure URI |
412 | | // when it's being considered for interception. Can only be true if |
413 | | // mPostRedirectChannelShouldIntercept is true. |
414 | | uint8_t mPostRedirectChannelShouldUpgrade : 1; |
415 | | |
416 | | // Set if the corresponding parent channel should force an interception to occur |
417 | | // before the network transaction is initiated. |
418 | | uint8_t mShouldParentIntercept : 1; |
419 | | |
420 | | // Set if the corresponding parent channel should suspend after a response |
421 | | // is synthesized. |
422 | | uint8_t mSuspendParentAfterSynthesizeResponse : 1; |
423 | | |
424 | | // Set if we get the result and cache |mNeedToReportBytesRead| |
425 | | uint8_t mCacheNeedToReportBytesReadInitialized : 1; |
426 | | |
427 | | // True if we need to tell the parent the size of unreported received data |
428 | | uint8_t mNeedToReportBytesRead : 1; |
429 | | |
430 | | void FinishInterceptedRedirect(); |
431 | | void CleanupRedirectingChannel(nsresult rv); |
432 | | |
433 | | // true after successful AsyncOpen until OnStopRequest completes. |
434 | 0 | bool RemoteChannelExists() { return mIPCOpen && !mKeptAlive; } |
435 | | |
436 | | void AssociateApplicationCache(const nsCString &groupID, |
437 | | const nsCString &clientID); |
438 | | void OnStartRequest(const nsresult& channelStatus, |
439 | | const nsHttpResponseHead& responseHead, |
440 | | const bool& useResponseHead, |
441 | | const nsHttpHeaderArray& requestHeaders, |
442 | | const ParentLoadInfoForwarderArgs& loadInfoForwarder, |
443 | | const bool& isFromCache, |
444 | | const bool& cacheEntryAvailable, |
445 | | const uint64_t& cacheEntryId, |
446 | | const int32_t& cacheFetchCount, |
447 | | const uint32_t& cacheExpirationTime, |
448 | | const nsCString& cachedCharset, |
449 | | const nsCString& securityInfoSerialization, |
450 | | const NetAddr& selfAddr, |
451 | | const NetAddr& peerAddr, |
452 | | const uint32_t& cacheKey, |
453 | | const nsCString& altDataType, |
454 | | const int64_t& altDataLen, |
455 | | const bool& aApplyConversion, |
456 | | const ResourceTimingStruct& aTiming); |
457 | | void MaybeDivertOnData(const nsCString& data, |
458 | | const uint64_t& offset, |
459 | | const uint32_t& count); |
460 | | void OnTransportAndData(const nsresult& channelStatus, |
461 | | const nsresult& status, |
462 | | const uint64_t& offset, |
463 | | const uint32_t& count, |
464 | | const nsCString& data); |
465 | | void OnStopRequest(const nsresult& channelStatus, |
466 | | const ResourceTimingStruct& timing, |
467 | | const nsHttpHeaderArray& aResponseTrailers); |
468 | | void MaybeDivertOnStop(const nsresult& aChannelStatus); |
469 | | void OnProgress(const int64_t& progress, const int64_t& progressMax); |
470 | | void OnStatus(const nsresult& status); |
471 | | void FailedAsyncOpen(const nsresult& status); |
472 | | void HandleAsyncAbort(); |
473 | | void Redirect1Begin(const uint32_t& registrarId, |
474 | | const URIParams& newUri, |
475 | | const uint32_t& newLoadFlags, |
476 | | const uint32_t& redirectFlags, |
477 | | const ParentLoadInfoForwarderArgs& loadInfoForwarder, |
478 | | const nsHttpResponseHead& responseHead, |
479 | | const nsACString& securityInfoSerialization, |
480 | | const uint64_t& channelId); |
481 | | bool Redirect3Complete(OverrideRunnable* aRunnable); |
482 | | void DeleteSelf(); |
483 | | |
484 | | // Create a a new channel to be used in a redirection, based on the provided |
485 | | // response headers. |
486 | | MOZ_MUST_USE nsresult SetupRedirect(nsIURI* uri, |
487 | | const nsHttpResponseHead* responseHead, |
488 | | const uint32_t& redirectFlags, |
489 | | nsIChannel** outChannel); |
490 | | |
491 | | // Perform a redirection without communicating with the parent process at all. |
492 | | void BeginNonIPCRedirect(nsIURI* responseURI, |
493 | | const nsHttpResponseHead* responseHead, |
494 | | bool responseRedirected); |
495 | | |
496 | | // Override the default security info pointer during a non-IPC redirection. |
497 | | void OverrideSecurityInfoForNonIPCRedirect(nsISupports* securityInfo); |
498 | | |
499 | | // Collect telemetry for the successful rate of OMT. |
500 | | void CollectOMTTelemetry(); |
501 | | |
502 | | friend class AssociateApplicationCacheEvent; |
503 | | friend class StartRequestEvent; |
504 | | friend class StopRequestEvent; |
505 | | friend class TransportAndDataEvent; |
506 | | friend class MaybeDivertOnDataHttpEvent; |
507 | | friend class MaybeDivertOnStopHttpEvent; |
508 | | friend class ProgressEvent; |
509 | | friend class StatusEvent; |
510 | | friend class FailedAsyncOpenEvent; |
511 | | friend class Redirect1Event; |
512 | | friend class Redirect3Event; |
513 | | friend class DeleteSelfEvent; |
514 | | friend class HttpFlushedForDiversionEvent; |
515 | | friend class CancelEvent; |
516 | | friend class HttpAsyncAborter<HttpChannelChild>; |
517 | | friend class InterceptStreamListener; |
518 | | friend class InterceptedChannelContent; |
519 | | friend class SyntheticDiversionListener; |
520 | | friend class HttpBackgroundChannelChild; |
521 | | friend class NeckoTargetChannelEvent<HttpChannelChild>; |
522 | | }; |
523 | | |
524 | | NS_DEFINE_STATIC_IID_ACCESSOR(HttpChannelChild, |
525 | | HTTP_CHANNEL_CHILD_IID) |
526 | | |
527 | | // A stream listener interposed between the nsInputStreamPump used for intercepted channels |
528 | | // and this channel's original listener. This is only used to ensure the original listener |
529 | | // sees the channel as the request object, and to synthesize OnStatus and OnProgress notifications. |
530 | | class InterceptStreamListener : public nsIStreamListener |
531 | | , public nsIProgressEventSink |
532 | | { |
533 | | RefPtr<HttpChannelChild> mOwner; |
534 | | nsCOMPtr<nsISupports> mContext; |
535 | 0 | virtual ~InterceptStreamListener() = default; |
536 | | public: |
537 | | InterceptStreamListener(HttpChannelChild* aOwner, nsISupports* aContext) |
538 | | : mOwner(aOwner) |
539 | | , mContext(aContext) |
540 | 0 | { |
541 | 0 | } |
542 | | |
543 | | NS_DECL_ISUPPORTS |
544 | | NS_DECL_NSIREQUESTOBSERVER |
545 | | NS_DECL_NSISTREAMLISTENER |
546 | | NS_DECL_NSIPROGRESSEVENTSINK |
547 | | |
548 | | void Cleanup(); |
549 | | }; |
550 | | |
551 | | //----------------------------------------------------------------------------- |
552 | | // inline functions |
553 | | //----------------------------------------------------------------------------- |
554 | | |
555 | | inline bool |
556 | | HttpChannelChild::IsSuspended() |
557 | 0 | { |
558 | 0 | return mSuspendCount != 0; |
559 | 0 | } |
560 | | |
561 | | } // namespace net |
562 | | } // namespace mozilla |
563 | | |
564 | | #endif // mozilla_net_HttpChannelChild_h |