/work/obj-fuzz/dist/include/mozilla/net/FTPChannelChild.h
Line | Count | Source (jump to first uncovered line) |
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_FTPChannelChild_h |
9 | | #define mozilla_net_FTPChannelChild_h |
10 | | |
11 | | #include "mozilla/UniquePtr.h" |
12 | | #include "mozilla/net/PFTPChannelChild.h" |
13 | | #include "mozilla/net/ChannelEventQueue.h" |
14 | | #include "nsBaseChannel.h" |
15 | | #include "nsIFTPChannel.h" |
16 | | #include "nsIUploadChannel.h" |
17 | | #include "nsIProxiedChannel.h" |
18 | | #include "nsIResumableChannel.h" |
19 | | #include "nsIChildChannel.h" |
20 | | #include "nsIDivertableChannel.h" |
21 | | #include "nsIEventTarget.h" |
22 | | |
23 | | #include "nsIStreamListener.h" |
24 | | #include "PrivateBrowsingChannel.h" |
25 | | |
26 | | class nsIEventTarget; |
27 | | |
28 | | namespace mozilla { |
29 | | |
30 | | namespace net { |
31 | | |
32 | | // This class inherits logic from nsBaseChannel that is not needed for an |
33 | | // e10s child channel, but it works. At some point we could slice up |
34 | | // nsBaseChannel and have a new class that has only the common logic for |
35 | | // nsFTPChannel/FTPChannelChild. |
36 | | |
37 | | class FTPChannelChild final : public PFTPChannelChild |
38 | | , public nsBaseChannel |
39 | | , public nsIFTPChannel |
40 | | , public nsIUploadChannel |
41 | | , public nsIResumableChannel |
42 | | , public nsIProxiedChannel |
43 | | , public nsIChildChannel |
44 | | , public nsIDivertableChannel |
45 | | { |
46 | | public: |
47 | | typedef ::nsIStreamListener nsIStreamListener; |
48 | | |
49 | | NS_DECL_ISUPPORTS_INHERITED |
50 | | NS_DECL_NSIFTPCHANNEL |
51 | | NS_DECL_NSIUPLOADCHANNEL |
52 | | NS_DECL_NSIRESUMABLECHANNEL |
53 | | NS_DECL_NSIPROXIEDCHANNEL |
54 | | NS_DECL_NSICHILDCHANNEL |
55 | | NS_DECL_NSIDIVERTABLECHANNEL |
56 | | |
57 | | NS_IMETHOD Cancel(nsresult status) override; |
58 | | NS_IMETHOD Suspend() override; |
59 | | NS_IMETHOD Resume() override; |
60 | | |
61 | | explicit FTPChannelChild(nsIURI* uri); |
62 | | |
63 | | void AddIPDLReference(); |
64 | | void ReleaseIPDLReference(); |
65 | | |
66 | | NS_IMETHOD AsyncOpen(nsIStreamListener* listener, nsISupports* aContext) override; |
67 | | |
68 | | // Note that we handle this ourselves, overriding the nsBaseChannel |
69 | | // default behavior, in order to be e10s-friendly. |
70 | | NS_IMETHOD IsPending(bool* result) override; |
71 | | |
72 | | nsresult OpenContentStream(bool async, |
73 | | nsIInputStream** stream, |
74 | | nsIChannel** channel) override; |
75 | | |
76 | | bool IsSuspended(); |
77 | | |
78 | | void FlushedForDiversion(); |
79 | | |
80 | | protected: |
81 | | virtual ~FTPChannelChild(); |
82 | | |
83 | | mozilla::ipc::IPCResult RecvOnStartRequest(const nsresult& aChannelStatus, |
84 | | const int64_t& aContentLength, |
85 | | const nsCString& aContentType, |
86 | | const PRTime& aLastModified, |
87 | | const nsCString& aEntityID, |
88 | | const URIParams& aURI) override; |
89 | | mozilla::ipc::IPCResult RecvOnDataAvailable(const nsresult& channelStatus, |
90 | | const nsCString& data, |
91 | | const uint64_t& offset, |
92 | | const uint32_t& count) override; |
93 | | mozilla::ipc::IPCResult RecvOnStopRequest(const nsresult& channelStatus, |
94 | | const nsCString &aErrorMsg, |
95 | | const bool &aUseUTF8) override; |
96 | | mozilla::ipc::IPCResult RecvFailedAsyncOpen(const nsresult& statusCode) override; |
97 | | mozilla::ipc::IPCResult RecvFlushedForDiversion() override; |
98 | | mozilla::ipc::IPCResult RecvDivertMessages() override; |
99 | | mozilla::ipc::IPCResult RecvDeleteSelf() override; |
100 | | |
101 | | void DoOnStartRequest(const nsresult& aChannelStatus, |
102 | | const int64_t& aContentLength, |
103 | | const nsCString& aContentType, |
104 | | const PRTime& aLastModified, |
105 | | const nsCString& aEntityID, |
106 | | const URIParams& aURI); |
107 | | void DoOnDataAvailable(const nsresult& channelStatus, |
108 | | const nsCString& data, |
109 | | const uint64_t& offset, |
110 | | const uint32_t& count); |
111 | | void MaybeDivertOnData(const nsCString& data, |
112 | | const uint64_t& offset, |
113 | | const uint32_t& count); |
114 | | void MaybeDivertOnStop(const nsresult& statusCode); |
115 | | void DoOnStopRequest(const nsresult& statusCode, |
116 | | const nsCString &aErrorMsg, |
117 | | bool aUseUTF8); |
118 | | void DoFailedAsyncOpen(const nsresult& statusCode); |
119 | | void DoDeleteSelf(); |
120 | | |
121 | | void SetupNeckoTarget() override; |
122 | | |
123 | | friend class FTPStartRequestEvent; |
124 | | friend class FTPDataAvailableEvent; |
125 | | friend class MaybeDivertOnDataFTPEvent; |
126 | | friend class FTPStopRequestEvent; |
127 | | friend class MaybeDivertOnStopFTPEvent; |
128 | | friend class FTPFailedAsyncOpenEvent; |
129 | | friend class FTPFlushedForDiversionEvent; |
130 | | friend class FTPDeleteSelfEvent; |
131 | | friend class NeckoTargetChannelEvent<FTPChannelChild>; |
132 | | |
133 | | private: |
134 | | nsCOMPtr<nsIInputStream> mUploadStream; |
135 | | |
136 | | bool mIPCOpen; |
137 | | RefPtr<ChannelEventQueue> mEventQ; |
138 | | |
139 | | // If nsUnknownDecoder is involved we queue onDataAvailable (and possibly |
140 | | // OnStopRequest) so that we can divert them if needed when the listener's |
141 | | // OnStartRequest is finally called |
142 | | nsTArray<UniquePtr<ChannelEvent>> mUnknownDecoderEventQ; |
143 | | bool mUnknownDecoderInvolved; |
144 | | |
145 | | bool mCanceled; |
146 | | uint32_t mSuspendCount; |
147 | | bool mIsPending; |
148 | | |
149 | | // This will only be true while DoOnStartRequest is in progress. |
150 | | // It is used to enforce that DivertToParent is only called during that time. |
151 | | bool mDuringOnStart = false; |
152 | | |
153 | | PRTime mLastModifiedTime; |
154 | | uint64_t mStartPos; |
155 | | nsCString mEntityID; |
156 | | |
157 | | // Once set, OnData and possibly OnStop will be diverted to the parent. |
158 | | bool mDivertingToParent; |
159 | | // Once set, no OnStart/OnData/OnStop callbacks should be received from the |
160 | | // parent channel, nor dequeued from the ChannelEventQueue. |
161 | | bool mFlushedForDiversion; |
162 | | // Set if SendSuspend is called. Determines if SendResume is needed when |
163 | | // diverting callbacks to parent. |
164 | | bool mSuspendSent; |
165 | | }; |
166 | | |
167 | | inline bool |
168 | | FTPChannelChild::IsSuspended() |
169 | 0 | { |
170 | 0 | return mSuspendCount != 0; |
171 | 0 | } |
172 | | |
173 | | } // namespace net |
174 | | } // namespace mozilla |
175 | | |
176 | | #endif // mozilla_net_FTPChannelChild_h |