Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
michael@0 | 1 | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* vim: set sw=2 ts=8 et tw=80 : */ |
michael@0 | 3 | |
michael@0 | 4 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 7 | |
michael@0 | 8 | #ifndef mozilla_net_FTPChannelChild_h |
michael@0 | 9 | #define mozilla_net_FTPChannelChild_h |
michael@0 | 10 | |
michael@0 | 11 | #include "mozilla/net/PFTPChannelChild.h" |
michael@0 | 12 | #include "mozilla/net/ChannelEventQueue.h" |
michael@0 | 13 | #include "nsBaseChannel.h" |
michael@0 | 14 | #include "nsIFTPChannel.h" |
michael@0 | 15 | #include "nsIUploadChannel.h" |
michael@0 | 16 | #include "nsIProxiedChannel.h" |
michael@0 | 17 | #include "nsIResumableChannel.h" |
michael@0 | 18 | #include "nsIChildChannel.h" |
michael@0 | 19 | #include "nsIDivertableChannel.h" |
michael@0 | 20 | |
michael@0 | 21 | #include "nsIStreamListener.h" |
michael@0 | 22 | #include "PrivateBrowsingChannel.h" |
michael@0 | 23 | |
michael@0 | 24 | namespace mozilla { |
michael@0 | 25 | namespace net { |
michael@0 | 26 | |
michael@0 | 27 | // This class inherits logic from nsBaseChannel that is not needed for an |
michael@0 | 28 | // e10s child channel, but it works. At some point we could slice up |
michael@0 | 29 | // nsBaseChannel and have a new class that has only the common logic for |
michael@0 | 30 | // nsFTPChannel/FTPChannelChild. |
michael@0 | 31 | |
michael@0 | 32 | class FTPChannelChild : public PFTPChannelChild |
michael@0 | 33 | , public nsBaseChannel |
michael@0 | 34 | , public nsIFTPChannel |
michael@0 | 35 | , public nsIUploadChannel |
michael@0 | 36 | , public nsIResumableChannel |
michael@0 | 37 | , public nsIProxiedChannel |
michael@0 | 38 | , public nsIChildChannel |
michael@0 | 39 | , public nsIDivertableChannel |
michael@0 | 40 | { |
michael@0 | 41 | public: |
michael@0 | 42 | typedef ::nsIStreamListener nsIStreamListener; |
michael@0 | 43 | |
michael@0 | 44 | NS_DECL_ISUPPORTS_INHERITED |
michael@0 | 45 | NS_DECL_NSIFTPCHANNEL |
michael@0 | 46 | NS_DECL_NSIUPLOADCHANNEL |
michael@0 | 47 | NS_DECL_NSIRESUMABLECHANNEL |
michael@0 | 48 | NS_DECL_NSIPROXIEDCHANNEL |
michael@0 | 49 | NS_DECL_NSICHILDCHANNEL |
michael@0 | 50 | NS_DECL_NSIDIVERTABLECHANNEL |
michael@0 | 51 | |
michael@0 | 52 | NS_IMETHOD Cancel(nsresult status); |
michael@0 | 53 | NS_IMETHOD Suspend(); |
michael@0 | 54 | NS_IMETHOD Resume(); |
michael@0 | 55 | |
michael@0 | 56 | FTPChannelChild(nsIURI* uri); |
michael@0 | 57 | virtual ~FTPChannelChild(); |
michael@0 | 58 | |
michael@0 | 59 | void AddIPDLReference(); |
michael@0 | 60 | void ReleaseIPDLReference(); |
michael@0 | 61 | |
michael@0 | 62 | NS_IMETHOD AsyncOpen(nsIStreamListener* listener, nsISupports* aContext); |
michael@0 | 63 | |
michael@0 | 64 | // Note that we handle this ourselves, overriding the nsBaseChannel |
michael@0 | 65 | // default behavior, in order to be e10s-friendly. |
michael@0 | 66 | NS_IMETHOD IsPending(bool* result); |
michael@0 | 67 | |
michael@0 | 68 | nsresult OpenContentStream(bool async, |
michael@0 | 69 | nsIInputStream** stream, |
michael@0 | 70 | nsIChannel** channel) MOZ_OVERRIDE; |
michael@0 | 71 | |
michael@0 | 72 | bool IsSuspended(); |
michael@0 | 73 | |
michael@0 | 74 | void FlushedForDiversion(); |
michael@0 | 75 | |
michael@0 | 76 | protected: |
michael@0 | 77 | bool RecvOnStartRequest(const nsresult& aChannelStatus, |
michael@0 | 78 | const int64_t& aContentLength, |
michael@0 | 79 | const nsCString& aContentType, |
michael@0 | 80 | const PRTime& aLastModified, |
michael@0 | 81 | const nsCString& aEntityID, |
michael@0 | 82 | const URIParams& aURI) MOZ_OVERRIDE; |
michael@0 | 83 | bool RecvOnDataAvailable(const nsresult& channelStatus, |
michael@0 | 84 | const nsCString& data, |
michael@0 | 85 | const uint64_t& offset, |
michael@0 | 86 | const uint32_t& count) MOZ_OVERRIDE; |
michael@0 | 87 | bool RecvOnStopRequest(const nsresult& channelStatus) MOZ_OVERRIDE; |
michael@0 | 88 | bool RecvFailedAsyncOpen(const nsresult& statusCode) MOZ_OVERRIDE; |
michael@0 | 89 | bool RecvFlushedForDiversion() MOZ_OVERRIDE; |
michael@0 | 90 | bool RecvDivertMessages() MOZ_OVERRIDE; |
michael@0 | 91 | bool RecvDeleteSelf() MOZ_OVERRIDE; |
michael@0 | 92 | |
michael@0 | 93 | void DoOnStartRequest(const nsresult& aChannelStatus, |
michael@0 | 94 | const int64_t& aContentLength, |
michael@0 | 95 | const nsCString& aContentType, |
michael@0 | 96 | const PRTime& aLastModified, |
michael@0 | 97 | const nsCString& aEntityID, |
michael@0 | 98 | const URIParams& aURI); |
michael@0 | 99 | void DoOnDataAvailable(const nsresult& channelStatus, |
michael@0 | 100 | const nsCString& data, |
michael@0 | 101 | const uint64_t& offset, |
michael@0 | 102 | const uint32_t& count); |
michael@0 | 103 | void DoOnStopRequest(const nsresult& statusCode); |
michael@0 | 104 | void DoFailedAsyncOpen(const nsresult& statusCode); |
michael@0 | 105 | void DoDeleteSelf(); |
michael@0 | 106 | |
michael@0 | 107 | friend class FTPStartRequestEvent; |
michael@0 | 108 | friend class FTPDataAvailableEvent; |
michael@0 | 109 | friend class FTPStopRequestEvent; |
michael@0 | 110 | friend class FTPFailedAsyncOpenEvent; |
michael@0 | 111 | friend class FTPDeleteSelfEvent; |
michael@0 | 112 | |
michael@0 | 113 | private: |
michael@0 | 114 | nsCOMPtr<nsIInputStream> mUploadStream; |
michael@0 | 115 | |
michael@0 | 116 | bool mIPCOpen; |
michael@0 | 117 | nsRefPtr<ChannelEventQueue> mEventQ; |
michael@0 | 118 | bool mCanceled; |
michael@0 | 119 | uint32_t mSuspendCount; |
michael@0 | 120 | bool mIsPending; |
michael@0 | 121 | bool mWasOpened; |
michael@0 | 122 | |
michael@0 | 123 | PRTime mLastModifiedTime; |
michael@0 | 124 | uint64_t mStartPos; |
michael@0 | 125 | nsCString mEntityID; |
michael@0 | 126 | |
michael@0 | 127 | // Once set, OnData and possibly OnStop will be diverted to the parent. |
michael@0 | 128 | bool mDivertingToParent; |
michael@0 | 129 | // Once set, no OnStart/OnData/OnStop callbacks should be received from the |
michael@0 | 130 | // parent channel, nor dequeued from the ChannelEventQueue. |
michael@0 | 131 | bool mFlushedForDiversion; |
michael@0 | 132 | // Set if SendSuspend is called. Determines if SendResume is needed when |
michael@0 | 133 | // diverting callbacks to parent. |
michael@0 | 134 | bool mSuspendSent; |
michael@0 | 135 | }; |
michael@0 | 136 | |
michael@0 | 137 | inline bool |
michael@0 | 138 | FTPChannelChild::IsSuspended() |
michael@0 | 139 | { |
michael@0 | 140 | return mSuspendCount != 0; |
michael@0 | 141 | } |
michael@0 | 142 | |
michael@0 | 143 | } // namespace net |
michael@0 | 144 | } // namespace mozilla |
michael@0 | 145 | |
michael@0 | 146 | #endif // mozilla_net_FTPChannelChild_h |