Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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_FTPChannelParent_h |
michael@0 | 9 | #define mozilla_net_FTPChannelParent_h |
michael@0 | 10 | |
michael@0 | 11 | #include "ADivertableParentChannel.h" |
michael@0 | 12 | #include "mozilla/net/PFTPChannelParent.h" |
michael@0 | 13 | #include "mozilla/net/NeckoParent.h" |
michael@0 | 14 | #include "nsIParentChannel.h" |
michael@0 | 15 | #include "nsIInterfaceRequestor.h" |
michael@0 | 16 | |
michael@0 | 17 | class nsFtpChannel; |
michael@0 | 18 | class nsILoadContext; |
michael@0 | 19 | |
michael@0 | 20 | namespace mozilla { |
michael@0 | 21 | namespace net { |
michael@0 | 22 | |
michael@0 | 23 | class FTPChannelParent : public PFTPChannelParent |
michael@0 | 24 | , public nsIParentChannel |
michael@0 | 25 | , public nsIInterfaceRequestor |
michael@0 | 26 | , public ADivertableParentChannel |
michael@0 | 27 | { |
michael@0 | 28 | public: |
michael@0 | 29 | NS_DECL_ISUPPORTS |
michael@0 | 30 | NS_DECL_NSIREQUESTOBSERVER |
michael@0 | 31 | NS_DECL_NSISTREAMLISTENER |
michael@0 | 32 | NS_DECL_NSIPARENTCHANNEL |
michael@0 | 33 | NS_DECL_NSIINTERFACEREQUESTOR |
michael@0 | 34 | |
michael@0 | 35 | FTPChannelParent(nsILoadContext* aLoadContext, PBOverrideStatus aOverrideStatus); |
michael@0 | 36 | virtual ~FTPChannelParent(); |
michael@0 | 37 | |
michael@0 | 38 | bool Init(const FTPChannelCreationArgs& aOpenArgs); |
michael@0 | 39 | |
michael@0 | 40 | // ADivertableParentChannel functions. |
michael@0 | 41 | void DivertTo(nsIStreamListener *aListener) MOZ_OVERRIDE; |
michael@0 | 42 | nsresult SuspendForDiversion() MOZ_OVERRIDE; |
michael@0 | 43 | |
michael@0 | 44 | // Calls OnStartRequest for "DivertTo" listener, then notifies child channel |
michael@0 | 45 | // that it should divert OnDataAvailable and OnStopRequest calls to this |
michael@0 | 46 | // parent channel. |
michael@0 | 47 | void StartDiversion(); |
michael@0 | 48 | |
michael@0 | 49 | // Handles calling OnStart/Stop if there are errors during diversion. |
michael@0 | 50 | // Called asynchronously from FailDiversion. |
michael@0 | 51 | void NotifyDiversionFailed(nsresult aErrorCode, bool aSkipResume = true); |
michael@0 | 52 | |
michael@0 | 53 | protected: |
michael@0 | 54 | // private, supporting function for ADivertableParentChannel. |
michael@0 | 55 | nsresult ResumeForDiversion(); |
michael@0 | 56 | |
michael@0 | 57 | // Asynchronously calls NotifyDiversionFailed. |
michael@0 | 58 | void FailDiversion(nsresult aErrorCode, bool aSkipResume = true); |
michael@0 | 59 | |
michael@0 | 60 | bool DoAsyncOpen(const URIParams& aURI, const uint64_t& aStartPos, |
michael@0 | 61 | const nsCString& aEntityID, |
michael@0 | 62 | const OptionalInputStreamParams& aUploadStream); |
michael@0 | 63 | |
michael@0 | 64 | // used to connect redirected-to channel in parent with just created |
michael@0 | 65 | // ChildChannel. Used during HTTP->FTP redirects. |
michael@0 | 66 | bool ConnectChannel(const uint32_t& channelId); |
michael@0 | 67 | |
michael@0 | 68 | virtual bool RecvCancel(const nsresult& status) MOZ_OVERRIDE; |
michael@0 | 69 | virtual bool RecvSuspend() MOZ_OVERRIDE; |
michael@0 | 70 | virtual bool RecvResume() MOZ_OVERRIDE; |
michael@0 | 71 | virtual bool RecvDivertOnDataAvailable(const nsCString& data, |
michael@0 | 72 | const uint64_t& offset, |
michael@0 | 73 | const uint32_t& count) MOZ_OVERRIDE; |
michael@0 | 74 | virtual bool RecvDivertOnStopRequest(const nsresult& statusCode) MOZ_OVERRIDE; |
michael@0 | 75 | virtual bool RecvDivertComplete() MOZ_OVERRIDE; |
michael@0 | 76 | |
michael@0 | 77 | virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE; |
michael@0 | 78 | |
michael@0 | 79 | nsRefPtr<nsFtpChannel> mChannel; |
michael@0 | 80 | |
michael@0 | 81 | bool mIPCClosed; |
michael@0 | 82 | |
michael@0 | 83 | nsCOMPtr<nsILoadContext> mLoadContext; |
michael@0 | 84 | |
michael@0 | 85 | PBOverrideStatus mPBOverride; |
michael@0 | 86 | |
michael@0 | 87 | // If OnStart/OnData/OnStop have been diverted from the child, forward them to |
michael@0 | 88 | // this listener. |
michael@0 | 89 | nsCOMPtr<nsIStreamListener> mDivertToListener; |
michael@0 | 90 | // Set to the canceled status value if the main channel was canceled. |
michael@0 | 91 | nsresult mStatus; |
michael@0 | 92 | // Once set, no OnStart/OnData/OnStop calls should be accepted; conversely, it |
michael@0 | 93 | // must be set when RecvDivertOnData/~DivertOnStop/~DivertComplete are |
michael@0 | 94 | // received from the child channel. |
michael@0 | 95 | bool mDivertingFromChild; |
michael@0 | 96 | // Set if OnStart|StopRequest was called during a diversion from the child. |
michael@0 | 97 | bool mDivertedOnStartRequest; |
michael@0 | 98 | |
michael@0 | 99 | // Set if we successfully suspended the nsHttpChannel for diversion. Unset |
michael@0 | 100 | // when we call ResumeForDiversion. |
michael@0 | 101 | bool mSuspendedForDiversion; |
michael@0 | 102 | }; |
michael@0 | 103 | |
michael@0 | 104 | } // namespace net |
michael@0 | 105 | } // namespace mozilla |
michael@0 | 106 | |
michael@0 | 107 | #endif // mozilla_net_FTPChannelParent_h |