netwerk/protocol/ftp/FTPChannelParent.h

branch
TOR_BUG_9701
changeset 11
deefc01c0e14
equal deleted inserted replaced
-1:000000000000 0:2a5ee460a1fc
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set sw=2 ts=8 et tw=80 : */
3
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7
8 #ifndef mozilla_net_FTPChannelParent_h
9 #define mozilla_net_FTPChannelParent_h
10
11 #include "ADivertableParentChannel.h"
12 #include "mozilla/net/PFTPChannelParent.h"
13 #include "mozilla/net/NeckoParent.h"
14 #include "nsIParentChannel.h"
15 #include "nsIInterfaceRequestor.h"
16
17 class nsFtpChannel;
18 class nsILoadContext;
19
20 namespace mozilla {
21 namespace net {
22
23 class FTPChannelParent : public PFTPChannelParent
24 , public nsIParentChannel
25 , public nsIInterfaceRequestor
26 , public ADivertableParentChannel
27 {
28 public:
29 NS_DECL_ISUPPORTS
30 NS_DECL_NSIREQUESTOBSERVER
31 NS_DECL_NSISTREAMLISTENER
32 NS_DECL_NSIPARENTCHANNEL
33 NS_DECL_NSIINTERFACEREQUESTOR
34
35 FTPChannelParent(nsILoadContext* aLoadContext, PBOverrideStatus aOverrideStatus);
36 virtual ~FTPChannelParent();
37
38 bool Init(const FTPChannelCreationArgs& aOpenArgs);
39
40 // ADivertableParentChannel functions.
41 void DivertTo(nsIStreamListener *aListener) MOZ_OVERRIDE;
42 nsresult SuspendForDiversion() MOZ_OVERRIDE;
43
44 // Calls OnStartRequest for "DivertTo" listener, then notifies child channel
45 // that it should divert OnDataAvailable and OnStopRequest calls to this
46 // parent channel.
47 void StartDiversion();
48
49 // Handles calling OnStart/Stop if there are errors during diversion.
50 // Called asynchronously from FailDiversion.
51 void NotifyDiversionFailed(nsresult aErrorCode, bool aSkipResume = true);
52
53 protected:
54 // private, supporting function for ADivertableParentChannel.
55 nsresult ResumeForDiversion();
56
57 // Asynchronously calls NotifyDiversionFailed.
58 void FailDiversion(nsresult aErrorCode, bool aSkipResume = true);
59
60 bool DoAsyncOpen(const URIParams& aURI, const uint64_t& aStartPos,
61 const nsCString& aEntityID,
62 const OptionalInputStreamParams& aUploadStream);
63
64 // used to connect redirected-to channel in parent with just created
65 // ChildChannel. Used during HTTP->FTP redirects.
66 bool ConnectChannel(const uint32_t& channelId);
67
68 virtual bool RecvCancel(const nsresult& status) MOZ_OVERRIDE;
69 virtual bool RecvSuspend() MOZ_OVERRIDE;
70 virtual bool RecvResume() MOZ_OVERRIDE;
71 virtual bool RecvDivertOnDataAvailable(const nsCString& data,
72 const uint64_t& offset,
73 const uint32_t& count) MOZ_OVERRIDE;
74 virtual bool RecvDivertOnStopRequest(const nsresult& statusCode) MOZ_OVERRIDE;
75 virtual bool RecvDivertComplete() MOZ_OVERRIDE;
76
77 virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
78
79 nsRefPtr<nsFtpChannel> mChannel;
80
81 bool mIPCClosed;
82
83 nsCOMPtr<nsILoadContext> mLoadContext;
84
85 PBOverrideStatus mPBOverride;
86
87 // If OnStart/OnData/OnStop have been diverted from the child, forward them to
88 // this listener.
89 nsCOMPtr<nsIStreamListener> mDivertToListener;
90 // Set to the canceled status value if the main channel was canceled.
91 nsresult mStatus;
92 // Once set, no OnStart/OnData/OnStop calls should be accepted; conversely, it
93 // must be set when RecvDivertOnData/~DivertOnStop/~DivertComplete are
94 // received from the child channel.
95 bool mDivertingFromChild;
96 // Set if OnStart|StopRequest was called during a diversion from the child.
97 bool mDivertedOnStartRequest;
98
99 // Set if we successfully suspended the nsHttpChannel for diversion. Unset
100 // when we call ResumeForDiversion.
101 bool mSuspendedForDiversion;
102 };
103
104 } // namespace net
105 } // namespace mozilla
106
107 #endif // mozilla_net_FTPChannelParent_h

mercurial