michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set sw=2 ts=8 et tw=80 : */ michael@0: michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_net_FTPChannelParent_h michael@0: #define mozilla_net_FTPChannelParent_h michael@0: michael@0: #include "ADivertableParentChannel.h" michael@0: #include "mozilla/net/PFTPChannelParent.h" michael@0: #include "mozilla/net/NeckoParent.h" michael@0: #include "nsIParentChannel.h" michael@0: #include "nsIInterfaceRequestor.h" michael@0: michael@0: class nsFtpChannel; michael@0: class nsILoadContext; michael@0: michael@0: namespace mozilla { michael@0: namespace net { michael@0: michael@0: class FTPChannelParent : public PFTPChannelParent michael@0: , public nsIParentChannel michael@0: , public nsIInterfaceRequestor michael@0: , public ADivertableParentChannel michael@0: { michael@0: public: michael@0: NS_DECL_ISUPPORTS michael@0: NS_DECL_NSIREQUESTOBSERVER michael@0: NS_DECL_NSISTREAMLISTENER michael@0: NS_DECL_NSIPARENTCHANNEL michael@0: NS_DECL_NSIINTERFACEREQUESTOR michael@0: michael@0: FTPChannelParent(nsILoadContext* aLoadContext, PBOverrideStatus aOverrideStatus); michael@0: virtual ~FTPChannelParent(); michael@0: michael@0: bool Init(const FTPChannelCreationArgs& aOpenArgs); michael@0: michael@0: // ADivertableParentChannel functions. michael@0: void DivertTo(nsIStreamListener *aListener) MOZ_OVERRIDE; michael@0: nsresult SuspendForDiversion() MOZ_OVERRIDE; michael@0: michael@0: // Calls OnStartRequest for "DivertTo" listener, then notifies child channel michael@0: // that it should divert OnDataAvailable and OnStopRequest calls to this michael@0: // parent channel. michael@0: void StartDiversion(); michael@0: michael@0: // Handles calling OnStart/Stop if there are errors during diversion. michael@0: // Called asynchronously from FailDiversion. michael@0: void NotifyDiversionFailed(nsresult aErrorCode, bool aSkipResume = true); michael@0: michael@0: protected: michael@0: // private, supporting function for ADivertableParentChannel. michael@0: nsresult ResumeForDiversion(); michael@0: michael@0: // Asynchronously calls NotifyDiversionFailed. michael@0: void FailDiversion(nsresult aErrorCode, bool aSkipResume = true); michael@0: michael@0: bool DoAsyncOpen(const URIParams& aURI, const uint64_t& aStartPos, michael@0: const nsCString& aEntityID, michael@0: const OptionalInputStreamParams& aUploadStream); michael@0: michael@0: // used to connect redirected-to channel in parent with just created michael@0: // ChildChannel. Used during HTTP->FTP redirects. michael@0: bool ConnectChannel(const uint32_t& channelId); michael@0: michael@0: virtual bool RecvCancel(const nsresult& status) MOZ_OVERRIDE; michael@0: virtual bool RecvSuspend() MOZ_OVERRIDE; michael@0: virtual bool RecvResume() MOZ_OVERRIDE; michael@0: virtual bool RecvDivertOnDataAvailable(const nsCString& data, michael@0: const uint64_t& offset, michael@0: const uint32_t& count) MOZ_OVERRIDE; michael@0: virtual bool RecvDivertOnStopRequest(const nsresult& statusCode) MOZ_OVERRIDE; michael@0: virtual bool RecvDivertComplete() MOZ_OVERRIDE; michael@0: michael@0: virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE; michael@0: michael@0: nsRefPtr mChannel; michael@0: michael@0: bool mIPCClosed; michael@0: michael@0: nsCOMPtr mLoadContext; michael@0: michael@0: PBOverrideStatus mPBOverride; michael@0: michael@0: // If OnStart/OnData/OnStop have been diverted from the child, forward them to michael@0: // this listener. michael@0: nsCOMPtr mDivertToListener; michael@0: // Set to the canceled status value if the main channel was canceled. michael@0: nsresult mStatus; michael@0: // Once set, no OnStart/OnData/OnStop calls should be accepted; conversely, it michael@0: // must be set when RecvDivertOnData/~DivertOnStop/~DivertComplete are michael@0: // received from the child channel. michael@0: bool mDivertingFromChild; michael@0: // Set if OnStart|StopRequest was called during a diversion from the child. michael@0: bool mDivertedOnStartRequest; michael@0: michael@0: // Set if we successfully suspended the nsHttpChannel for diversion. Unset michael@0: // when we call ResumeForDiversion. michael@0: bool mSuspendedForDiversion; michael@0: }; michael@0: michael@0: } // namespace net michael@0: } // namespace mozilla michael@0: michael@0: #endif // mozilla_net_FTPChannelParent_h