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_ADocumentChannelBridge_h
8 #define mozilla_net_ADocumentChannelBridge_h
9 
10 #include "mozilla/net/PDocumentChannelParent.h"
11 #include "mozilla/dom/nsCSPContext.h"
12 
13 namespace mozilla {
14 namespace net {
15 
16 /**
17  * ADocumentChannelBridge is the interface for DocumentLoadListener to
18  * communicate with the nsIChannel placeholder in the docshell. It may be
19  * implemented over IPDL.
20  */
21 class ADocumentChannelBridge {
22  public:
23   NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
24 
25   // Notify the destination docshell that we're not going to send
26   // a response to it (usually because we've redirected to a different
27   // process), and drop any references to the parent DocumentLoadListener.
28   // This should remove the nsIChannel from the loadgroup, and
29   // fire OnStart/StopRequest with aStatus.
30   // aLoadGroupStatus is used as mStatus when we remove the child channel
31   // from the loadgroup (but aStatus is passed as the parameter to
32   // RemoveRequest).
33   // We do this so we can remove using NS_BINDING_RETARGETED, but still have
34   // the channel not be in an error state.
35   virtual void DisconnectChildListeners(nsresult aStatus,
36                                         nsresult aLoadGroupStatus) = 0;
37 
38   // Delete the bridge, and drop any refs to the DocumentLoadListener
39   virtual void Delete() = 0;
40 
41   // Initate a switch from the DocumentChannel to the protocol-specific
42   // real channel.
43   virtual RefPtr<PDocumentChannelParent::RedirectToRealChannelPromise>
44   RedirectToRealChannel(
45       nsTArray<ipc::Endpoint<extensions::PStreamFilterParent>>&&
46           aStreamFilterEndpoints,
47       uint32_t aRedirectFlags, uint32_t aLoadFlags) = 0;
48 
49   // Returns the process id that this bridge is connected to.
50   // If 0 indicates that the load is started from the parent process.
51   virtual base::ProcessId OtherPid() const = 0;
52 
53  protected:
54   virtual ~ADocumentChannelBridge() = default;
55 };
56 
57 }  // namespace net
58 }  // namespace mozilla
59 
60 #endif  // mozilla_net_ADocumentChannelBridge_h
61