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 #include "nsIAsyncVerifyRedirectCallback.h"
15 
16 namespace mozilla {
17 namespace net {
18 
19 class ParentProcessDocumentChannel : public DocumentChannel,
20                                      public nsIAsyncVerifyRedirectCallback,
21                                      public nsIObserver {
22  public:
23   ParentProcessDocumentChannel(nsDocShellLoadState* aLoadState,
24                                class LoadInfo* aLoadInfo,
25                                nsLoadFlags aLoadFlags, uint32_t aCacheKey,
26                                bool aUriModified, bool aIsXFOError);
27 
28   NS_DECL_ISUPPORTS_INHERITED
29   NS_DECL_NSIASYNCVERIFYREDIRECTCALLBACK
30   NS_DECL_NSIOBSERVER
31 
32   NS_IMETHOD AsyncOpen(nsIStreamListener* aListener) override;
33   NS_IMETHOD Cancel(nsresult aStatusCode) override;
34 
35   RefPtr<PDocumentChannelParent::RedirectToRealChannelPromise>
36   RedirectToRealChannel(
37       nsTArray<ipc::Endpoint<extensions::PStreamFilterParent>>&&
38           aStreamFilterEndpoints,
39       uint32_t aRedirectFlags, uint32_t aLoadFlags);
40 
41  private:
42   virtual ~ParentProcessDocumentChannel();
43   void RemoveObserver();
44 
45   RefPtr<DocumentLoadListener> mDocumentLoadListener;
46   nsTArray<ipc::Endpoint<extensions::PStreamFilterParent>>
47       mStreamFilterEndpoints;
48   MozPromiseHolder<PDocumentChannelParent::RedirectToRealChannelPromise>
49       mPromise;
50   bool mRequestObserversCalled = false;
51 };
52 
53 }  // namespace net
54 }  // namespace mozilla
55 
56 #endif  // mozilla_net_ParentProcessDocumentChannel_h
57