1 /* vim: set sw=2 ts=8 et tw=80 : */
2 
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 
7 #ifndef mozilla_net_ParentProcessDocumentChannel_h
8 #define mozilla_net_ParentProcessDocumentChannel_h
9 
10 #include "mozilla/ipc/ProtocolUtils.h"
11 #include "mozilla/net/DocumentChannel.h"
12 #include "mozilla/net/DocumentLoadListener.h"
13 #include "nsIObserver.h"
14 
15 namespace mozilla {
16 namespace net {
17 
18 class ParentProcessDocumentChannel : public DocumentChannel,
19                                      public nsIAsyncVerifyRedirectCallback,
20                                      public nsIObserver {
21  public:
22   ParentProcessDocumentChannel(nsDocShellLoadState* aLoadState,
23                                class LoadInfo* aLoadInfo,
24                                nsLoadFlags aLoadFlags, uint32_t aCacheKey,
25                                bool aUriModified, bool aIsXFOError);
26 
27   NS_DECL_ISUPPORTS_INHERITED
28   NS_DECL_NSIASYNCVERIFYREDIRECTCALLBACK
29   NS_DECL_NSIOBSERVER
30 
31   NS_IMETHOD AsyncOpen(nsIStreamListener* aListener) override;
32   NS_IMETHOD Cancel(nsresult aStatusCode) override;
33 
34   RefPtr<PDocumentChannelParent::RedirectToRealChannelPromise>
35   RedirectToRealChannel(
36       nsTArray<ipc::Endpoint<extensions::PStreamFilterParent>>&&
37           aStreamFilterEndpoints,
38       uint32_t aRedirectFlags, uint32_t aLoadFlags);
39 
40  private:
41   virtual ~ParentProcessDocumentChannel();
42   void RemoveObserver();
43 
44   RefPtr<DocumentLoadListener> mDocumentLoadListener;
45   nsTArray<ipc::Endpoint<extensions::PStreamFilterParent>>
46       mStreamFilterEndpoints;
47   MozPromiseHolder<PDocumentChannelParent::RedirectToRealChannelPromise>
48       mPromise;
49   bool mRequestObserversCalled = false;
50 };
51 
52 }  // namespace net
53 }  // namespace mozilla
54 
55 #endif  // mozilla_net_ParentProcessDocumentChannel_h
56