1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/netwerk/protocol/ftp/FTPChannelChild.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,146 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim: set sw=2 ts=8 et tw=80 : */ 1.6 + 1.7 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.8 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.9 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.10 + 1.11 +#ifndef mozilla_net_FTPChannelChild_h 1.12 +#define mozilla_net_FTPChannelChild_h 1.13 + 1.14 +#include "mozilla/net/PFTPChannelChild.h" 1.15 +#include "mozilla/net/ChannelEventQueue.h" 1.16 +#include "nsBaseChannel.h" 1.17 +#include "nsIFTPChannel.h" 1.18 +#include "nsIUploadChannel.h" 1.19 +#include "nsIProxiedChannel.h" 1.20 +#include "nsIResumableChannel.h" 1.21 +#include "nsIChildChannel.h" 1.22 +#include "nsIDivertableChannel.h" 1.23 + 1.24 +#include "nsIStreamListener.h" 1.25 +#include "PrivateBrowsingChannel.h" 1.26 + 1.27 +namespace mozilla { 1.28 +namespace net { 1.29 + 1.30 +// This class inherits logic from nsBaseChannel that is not needed for an 1.31 +// e10s child channel, but it works. At some point we could slice up 1.32 +// nsBaseChannel and have a new class that has only the common logic for 1.33 +// nsFTPChannel/FTPChannelChild. 1.34 + 1.35 +class FTPChannelChild : public PFTPChannelChild 1.36 + , public nsBaseChannel 1.37 + , public nsIFTPChannel 1.38 + , public nsIUploadChannel 1.39 + , public nsIResumableChannel 1.40 + , public nsIProxiedChannel 1.41 + , public nsIChildChannel 1.42 + , public nsIDivertableChannel 1.43 +{ 1.44 +public: 1.45 + typedef ::nsIStreamListener nsIStreamListener; 1.46 + 1.47 + NS_DECL_ISUPPORTS_INHERITED 1.48 + NS_DECL_NSIFTPCHANNEL 1.49 + NS_DECL_NSIUPLOADCHANNEL 1.50 + NS_DECL_NSIRESUMABLECHANNEL 1.51 + NS_DECL_NSIPROXIEDCHANNEL 1.52 + NS_DECL_NSICHILDCHANNEL 1.53 + NS_DECL_NSIDIVERTABLECHANNEL 1.54 + 1.55 + NS_IMETHOD Cancel(nsresult status); 1.56 + NS_IMETHOD Suspend(); 1.57 + NS_IMETHOD Resume(); 1.58 + 1.59 + FTPChannelChild(nsIURI* uri); 1.60 + virtual ~FTPChannelChild(); 1.61 + 1.62 + void AddIPDLReference(); 1.63 + void ReleaseIPDLReference(); 1.64 + 1.65 + NS_IMETHOD AsyncOpen(nsIStreamListener* listener, nsISupports* aContext); 1.66 + 1.67 + // Note that we handle this ourselves, overriding the nsBaseChannel 1.68 + // default behavior, in order to be e10s-friendly. 1.69 + NS_IMETHOD IsPending(bool* result); 1.70 + 1.71 + nsresult OpenContentStream(bool async, 1.72 + nsIInputStream** stream, 1.73 + nsIChannel** channel) MOZ_OVERRIDE; 1.74 + 1.75 + bool IsSuspended(); 1.76 + 1.77 + void FlushedForDiversion(); 1.78 + 1.79 +protected: 1.80 + bool RecvOnStartRequest(const nsresult& aChannelStatus, 1.81 + const int64_t& aContentLength, 1.82 + const nsCString& aContentType, 1.83 + const PRTime& aLastModified, 1.84 + const nsCString& aEntityID, 1.85 + const URIParams& aURI) MOZ_OVERRIDE; 1.86 + bool RecvOnDataAvailable(const nsresult& channelStatus, 1.87 + const nsCString& data, 1.88 + const uint64_t& offset, 1.89 + const uint32_t& count) MOZ_OVERRIDE; 1.90 + bool RecvOnStopRequest(const nsresult& channelStatus) MOZ_OVERRIDE; 1.91 + bool RecvFailedAsyncOpen(const nsresult& statusCode) MOZ_OVERRIDE; 1.92 + bool RecvFlushedForDiversion() MOZ_OVERRIDE; 1.93 + bool RecvDivertMessages() MOZ_OVERRIDE; 1.94 + bool RecvDeleteSelf() MOZ_OVERRIDE; 1.95 + 1.96 + void DoOnStartRequest(const nsresult& aChannelStatus, 1.97 + const int64_t& aContentLength, 1.98 + const nsCString& aContentType, 1.99 + const PRTime& aLastModified, 1.100 + const nsCString& aEntityID, 1.101 + const URIParams& aURI); 1.102 + void DoOnDataAvailable(const nsresult& channelStatus, 1.103 + const nsCString& data, 1.104 + const uint64_t& offset, 1.105 + const uint32_t& count); 1.106 + void DoOnStopRequest(const nsresult& statusCode); 1.107 + void DoFailedAsyncOpen(const nsresult& statusCode); 1.108 + void DoDeleteSelf(); 1.109 + 1.110 + friend class FTPStartRequestEvent; 1.111 + friend class FTPDataAvailableEvent; 1.112 + friend class FTPStopRequestEvent; 1.113 + friend class FTPFailedAsyncOpenEvent; 1.114 + friend class FTPDeleteSelfEvent; 1.115 + 1.116 +private: 1.117 + nsCOMPtr<nsIInputStream> mUploadStream; 1.118 + 1.119 + bool mIPCOpen; 1.120 + nsRefPtr<ChannelEventQueue> mEventQ; 1.121 + bool mCanceled; 1.122 + uint32_t mSuspendCount; 1.123 + bool mIsPending; 1.124 + bool mWasOpened; 1.125 + 1.126 + PRTime mLastModifiedTime; 1.127 + uint64_t mStartPos; 1.128 + nsCString mEntityID; 1.129 + 1.130 + // Once set, OnData and possibly OnStop will be diverted to the parent. 1.131 + bool mDivertingToParent; 1.132 + // Once set, no OnStart/OnData/OnStop callbacks should be received from the 1.133 + // parent channel, nor dequeued from the ChannelEventQueue. 1.134 + bool mFlushedForDiversion; 1.135 + // Set if SendSuspend is called. Determines if SendResume is needed when 1.136 + // diverting callbacks to parent. 1.137 + bool mSuspendSent; 1.138 +}; 1.139 + 1.140 +inline bool 1.141 +FTPChannelChild::IsSuspended() 1.142 +{ 1.143 + return mSuspendCount != 0; 1.144 +} 1.145 + 1.146 +} // namespace net 1.147 +} // namespace mozilla 1.148 + 1.149 +#endif // mozilla_net_FTPChannelChild_h