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_DocumentChannelParent_h 8 #define mozilla_net_DocumentChannelParent_h 9 10 #include "mozilla/net/DocumentLoadListener.h" 11 #include "mozilla/net/PDocumentChannelParent.h" 12 13 namespace mozilla { 14 namespace dom { 15 class CanonicalBrowsingContext; 16 } 17 namespace net { 18 19 /** 20 * An actor that forwards all changes across to DocumentChannelChild, the 21 * nsIChannel implementation owned by a content process docshell. 22 */ 23 class DocumentChannelParent final 24 : public PDocumentChannelParent, 25 public DocumentLoadListener::ObjectUpgradeHandler { 26 public: 27 NS_INLINE_DECL_REFCOUNTING(DocumentChannelParent, override); 28 29 explicit DocumentChannelParent(); 30 31 bool Init(dom::CanonicalBrowsingContext* aContext, 32 const DocumentChannelCreationArgs& aArgs); 33 34 // PDocumentChannelParent RecvCancel(const nsresult & aStatus)35 bool RecvCancel(const nsresult& aStatus) { 36 if (mDocumentLoadListener) { 37 mDocumentLoadListener->Cancel(aStatus); 38 } 39 return true; 40 } ActorDestroy(ActorDestroyReason aWhy)41 void ActorDestroy(ActorDestroyReason aWhy) override { 42 if (mDocumentLoadListener) { 43 mDocumentLoadListener->Cancel(NS_BINDING_ABORTED); 44 } 45 } 46 47 private: 48 RefPtr<ObjectUpgradePromise> UpgradeObjectLoad() override; 49 50 RefPtr<PDocumentChannelParent::RedirectToRealChannelPromise> 51 RedirectToRealChannel( 52 nsTArray<ipc::Endpoint<extensions::PStreamFilterParent>>&& 53 aStreamFilterEndpoints, 54 uint32_t aRedirectFlags, uint32_t aLoadFlags); 55 56 virtual ~DocumentChannelParent(); 57 58 RefPtr<DocumentLoadListener> mDocumentLoadListener; 59 }; 60 61 } // namespace net 62 } // namespace mozilla 63 64 #endif // mozilla_net_DocumentChannelParent_h 65