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_FTPChannelChild_h michael@0: #define mozilla_net_FTPChannelChild_h michael@0: michael@0: #include "mozilla/net/PFTPChannelChild.h" michael@0: #include "mozilla/net/ChannelEventQueue.h" michael@0: #include "nsBaseChannel.h" michael@0: #include "nsIFTPChannel.h" michael@0: #include "nsIUploadChannel.h" michael@0: #include "nsIProxiedChannel.h" michael@0: #include "nsIResumableChannel.h" michael@0: #include "nsIChildChannel.h" michael@0: #include "nsIDivertableChannel.h" michael@0: michael@0: #include "nsIStreamListener.h" michael@0: #include "PrivateBrowsingChannel.h" michael@0: michael@0: namespace mozilla { michael@0: namespace net { michael@0: michael@0: // This class inherits logic from nsBaseChannel that is not needed for an michael@0: // e10s child channel, but it works. At some point we could slice up michael@0: // nsBaseChannel and have a new class that has only the common logic for michael@0: // nsFTPChannel/FTPChannelChild. michael@0: michael@0: class FTPChannelChild : public PFTPChannelChild michael@0: , public nsBaseChannel michael@0: , public nsIFTPChannel michael@0: , public nsIUploadChannel michael@0: , public nsIResumableChannel michael@0: , public nsIProxiedChannel michael@0: , public nsIChildChannel michael@0: , public nsIDivertableChannel michael@0: { michael@0: public: michael@0: typedef ::nsIStreamListener nsIStreamListener; michael@0: michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: NS_DECL_NSIFTPCHANNEL michael@0: NS_DECL_NSIUPLOADCHANNEL michael@0: NS_DECL_NSIRESUMABLECHANNEL michael@0: NS_DECL_NSIPROXIEDCHANNEL michael@0: NS_DECL_NSICHILDCHANNEL michael@0: NS_DECL_NSIDIVERTABLECHANNEL michael@0: michael@0: NS_IMETHOD Cancel(nsresult status); michael@0: NS_IMETHOD Suspend(); michael@0: NS_IMETHOD Resume(); michael@0: michael@0: FTPChannelChild(nsIURI* uri); michael@0: virtual ~FTPChannelChild(); michael@0: michael@0: void AddIPDLReference(); michael@0: void ReleaseIPDLReference(); michael@0: michael@0: NS_IMETHOD AsyncOpen(nsIStreamListener* listener, nsISupports* aContext); michael@0: michael@0: // Note that we handle this ourselves, overriding the nsBaseChannel michael@0: // default behavior, in order to be e10s-friendly. michael@0: NS_IMETHOD IsPending(bool* result); michael@0: michael@0: nsresult OpenContentStream(bool async, michael@0: nsIInputStream** stream, michael@0: nsIChannel** channel) MOZ_OVERRIDE; michael@0: michael@0: bool IsSuspended(); michael@0: michael@0: void FlushedForDiversion(); michael@0: michael@0: protected: michael@0: bool RecvOnStartRequest(const nsresult& aChannelStatus, michael@0: const int64_t& aContentLength, michael@0: const nsCString& aContentType, michael@0: const PRTime& aLastModified, michael@0: const nsCString& aEntityID, michael@0: const URIParams& aURI) MOZ_OVERRIDE; michael@0: bool RecvOnDataAvailable(const nsresult& channelStatus, michael@0: const nsCString& data, michael@0: const uint64_t& offset, michael@0: const uint32_t& count) MOZ_OVERRIDE; michael@0: bool RecvOnStopRequest(const nsresult& channelStatus) MOZ_OVERRIDE; michael@0: bool RecvFailedAsyncOpen(const nsresult& statusCode) MOZ_OVERRIDE; michael@0: bool RecvFlushedForDiversion() MOZ_OVERRIDE; michael@0: bool RecvDivertMessages() MOZ_OVERRIDE; michael@0: bool RecvDeleteSelf() MOZ_OVERRIDE; michael@0: michael@0: void DoOnStartRequest(const nsresult& aChannelStatus, michael@0: const int64_t& aContentLength, michael@0: const nsCString& aContentType, michael@0: const PRTime& aLastModified, michael@0: const nsCString& aEntityID, michael@0: const URIParams& aURI); michael@0: void DoOnDataAvailable(const nsresult& channelStatus, michael@0: const nsCString& data, michael@0: const uint64_t& offset, michael@0: const uint32_t& count); michael@0: void DoOnStopRequest(const nsresult& statusCode); michael@0: void DoFailedAsyncOpen(const nsresult& statusCode); michael@0: void DoDeleteSelf(); michael@0: michael@0: friend class FTPStartRequestEvent; michael@0: friend class FTPDataAvailableEvent; michael@0: friend class FTPStopRequestEvent; michael@0: friend class FTPFailedAsyncOpenEvent; michael@0: friend class FTPDeleteSelfEvent; michael@0: michael@0: private: michael@0: nsCOMPtr mUploadStream; michael@0: michael@0: bool mIPCOpen; michael@0: nsRefPtr mEventQ; michael@0: bool mCanceled; michael@0: uint32_t mSuspendCount; michael@0: bool mIsPending; michael@0: bool mWasOpened; michael@0: michael@0: PRTime mLastModifiedTime; michael@0: uint64_t mStartPos; michael@0: nsCString mEntityID; michael@0: michael@0: // Once set, OnData and possibly OnStop will be diverted to the parent. michael@0: bool mDivertingToParent; michael@0: // Once set, no OnStart/OnData/OnStop callbacks should be received from the michael@0: // parent channel, nor dequeued from the ChannelEventQueue. michael@0: bool mFlushedForDiversion; michael@0: // Set if SendSuspend is called. Determines if SendResume is needed when michael@0: // diverting callbacks to parent. michael@0: bool mSuspendSent; michael@0: }; michael@0: michael@0: inline bool michael@0: FTPChannelChild::IsSuspended() michael@0: { michael@0: return mSuspendCount != 0; michael@0: } michael@0: michael@0: } // namespace net michael@0: } // namespace mozilla michael@0: michael@0: #endif // mozilla_net_FTPChannelChild_h