2010-08-10 11:47:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set sw=2 ts=8 et tw=80 : */
|
|
|
|
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-08-10 11:47:00 -07:00
|
|
|
|
|
|
|
#ifndef mozilla_net_FTPChannelChild_h
|
|
|
|
#define mozilla_net_FTPChannelChild_h
|
|
|
|
|
|
|
|
#include "mozilla/net/PFTPChannelChild.h"
|
|
|
|
#include "mozilla/net/ChannelEventQueue.h"
|
|
|
|
#include "nsBaseChannel.h"
|
|
|
|
#include "nsIFTPChannel.h"
|
|
|
|
#include "nsIUploadChannel.h"
|
|
|
|
#include "nsIProxiedChannel.h"
|
|
|
|
#include "nsIResumableChannel.h"
|
2010-11-23 14:56:06 -08:00
|
|
|
#include "nsIChildChannel.h"
|
2014-03-10 15:04:28 -07:00
|
|
|
#include "nsIDivertableChannel.h"
|
2010-08-10 11:47:00 -07:00
|
|
|
|
|
|
|
#include "nsIStreamListener.h"
|
2012-09-04 17:37:45 -07:00
|
|
|
#include "PrivateBrowsingChannel.h"
|
2010-08-10 11:47:00 -07:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace net {
|
|
|
|
|
|
|
|
// This class inherits logic from nsBaseChannel that is not needed for an
|
|
|
|
// e10s child channel, but it works. At some point we could slice up
|
|
|
|
// nsBaseChannel and have a new class that has only the common logic for
|
|
|
|
// nsFTPChannel/FTPChannelChild.
|
|
|
|
|
|
|
|
class FTPChannelChild : public PFTPChannelChild
|
|
|
|
, public nsBaseChannel
|
|
|
|
, public nsIFTPChannel
|
|
|
|
, public nsIUploadChannel
|
|
|
|
, public nsIResumableChannel
|
|
|
|
, public nsIProxiedChannel
|
2010-11-23 14:56:06 -08:00
|
|
|
, public nsIChildChannel
|
2014-03-10 15:04:28 -07:00
|
|
|
, public nsIDivertableChannel
|
2010-08-10 11:47:00 -07:00
|
|
|
{
|
|
|
|
public:
|
2010-11-23 14:56:06 -08:00
|
|
|
typedef ::nsIStreamListener nsIStreamListener;
|
|
|
|
|
2010-08-10 11:47:00 -07:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_NSIFTPCHANNEL
|
|
|
|
NS_DECL_NSIUPLOADCHANNEL
|
|
|
|
NS_DECL_NSIRESUMABLECHANNEL
|
|
|
|
NS_DECL_NSIPROXIEDCHANNEL
|
2010-11-23 14:56:06 -08:00
|
|
|
NS_DECL_NSICHILDCHANNEL
|
2014-03-10 15:04:28 -07:00
|
|
|
NS_DECL_NSIDIVERTABLECHANNEL
|
2010-08-10 11:47:00 -07:00
|
|
|
|
|
|
|
NS_IMETHOD Cancel(nsresult status);
|
|
|
|
NS_IMETHOD Suspend();
|
|
|
|
NS_IMETHOD Resume();
|
|
|
|
|
2014-08-05 06:20:50 -07:00
|
|
|
explicit FTPChannelChild(nsIURI* uri);
|
2010-08-10 11:47:00 -07:00
|
|
|
|
|
|
|
void AddIPDLReference();
|
|
|
|
void ReleaseIPDLReference();
|
|
|
|
|
2010-11-23 14:56:06 -08:00
|
|
|
NS_IMETHOD AsyncOpen(nsIStreamListener* listener, nsISupports* aContext);
|
2010-08-10 11:47:00 -07:00
|
|
|
|
|
|
|
// Note that we handle this ourselves, overriding the nsBaseChannel
|
|
|
|
// default behavior, in order to be e10s-friendly.
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD IsPending(bool* result);
|
2010-08-10 11:47:00 -07:00
|
|
|
|
2012-07-06 11:15:45 -07:00
|
|
|
nsresult OpenContentStream(bool async,
|
|
|
|
nsIInputStream** stream,
|
|
|
|
nsIChannel** channel) MOZ_OVERRIDE;
|
2010-08-10 11:47:00 -07:00
|
|
|
|
|
|
|
bool IsSuspended();
|
|
|
|
|
2014-03-10 15:04:28 -07:00
|
|
|
void FlushedForDiversion();
|
|
|
|
|
2010-08-10 11:47:00 -07:00
|
|
|
protected:
|
2014-07-08 14:23:18 -07:00
|
|
|
virtual ~FTPChannelChild();
|
|
|
|
|
2014-04-07 11:26:22 -07:00
|
|
|
bool RecvOnStartRequest(const nsresult& aChannelStatus,
|
|
|
|
const int64_t& aContentLength,
|
2012-07-06 11:15:45 -07:00
|
|
|
const nsCString& aContentType,
|
|
|
|
const PRTime& aLastModified,
|
|
|
|
const nsCString& aEntityID,
|
2012-08-23 12:33:46 -07:00
|
|
|
const URIParams& aURI) MOZ_OVERRIDE;
|
2014-04-07 11:26:22 -07:00
|
|
|
bool RecvOnDataAvailable(const nsresult& channelStatus,
|
|
|
|
const nsCString& data,
|
2012-09-05 19:41:02 -07:00
|
|
|
const uint64_t& offset,
|
2012-08-22 08:56:38 -07:00
|
|
|
const uint32_t& count) MOZ_OVERRIDE;
|
2014-04-07 11:26:22 -07:00
|
|
|
bool RecvOnStopRequest(const nsresult& channelStatus) MOZ_OVERRIDE;
|
2012-07-06 11:15:45 -07:00
|
|
|
bool RecvFailedAsyncOpen(const nsresult& statusCode) MOZ_OVERRIDE;
|
2014-03-10 15:04:28 -07:00
|
|
|
bool RecvFlushedForDiversion() MOZ_OVERRIDE;
|
|
|
|
bool RecvDivertMessages() MOZ_OVERRIDE;
|
2012-07-06 11:15:45 -07:00
|
|
|
bool RecvDeleteSelf() MOZ_OVERRIDE;
|
2010-08-10 11:47:00 -07:00
|
|
|
|
2014-04-07 11:26:22 -07:00
|
|
|
void DoOnStartRequest(const nsresult& aChannelStatus,
|
|
|
|
const int64_t& aContentLength,
|
2010-08-10 11:47:00 -07:00
|
|
|
const nsCString& aContentType,
|
|
|
|
const PRTime& aLastModified,
|
|
|
|
const nsCString& aEntityID,
|
2012-08-23 12:33:46 -07:00
|
|
|
const URIParams& aURI);
|
2014-04-07 11:26:22 -07:00
|
|
|
void DoOnDataAvailable(const nsresult& channelStatus,
|
|
|
|
const nsCString& data,
|
2012-09-05 19:41:02 -07:00
|
|
|
const uint64_t& offset,
|
2012-08-22 08:56:38 -07:00
|
|
|
const uint32_t& count);
|
2010-08-10 11:47:00 -07:00
|
|
|
void DoOnStopRequest(const nsresult& statusCode);
|
2012-01-10 23:19:17 -08:00
|
|
|
void DoFailedAsyncOpen(const nsresult& statusCode);
|
2010-11-23 14:56:06 -08:00
|
|
|
void DoDeleteSelf();
|
2010-08-10 11:47:00 -07:00
|
|
|
|
|
|
|
friend class FTPStartRequestEvent;
|
|
|
|
friend class FTPDataAvailableEvent;
|
|
|
|
friend class FTPStopRequestEvent;
|
2012-01-10 23:19:17 -08:00
|
|
|
friend class FTPFailedAsyncOpenEvent;
|
2010-11-23 14:56:06 -08:00
|
|
|
friend class FTPDeleteSelfEvent;
|
2010-08-10 11:47:00 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
nsCOMPtr<nsIInputStream> mUploadStream;
|
|
|
|
|
|
|
|
bool mIPCOpen;
|
2013-06-04 16:10:55 -07:00
|
|
|
nsRefPtr<ChannelEventQueue> mEventQ;
|
2010-08-10 11:47:00 -07:00
|
|
|
bool mCanceled;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mSuspendCount;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIsPending;
|
|
|
|
bool mWasOpened;
|
2010-08-10 11:47:00 -07:00
|
|
|
|
|
|
|
PRTime mLastModifiedTime;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t mStartPos;
|
2010-08-10 11:47:00 -07:00
|
|
|
nsCString mEntityID;
|
2014-03-10 15:04:28 -07:00
|
|
|
|
|
|
|
// Once set, OnData and possibly OnStop will be diverted to the parent.
|
|
|
|
bool mDivertingToParent;
|
|
|
|
// Once set, no OnStart/OnData/OnStop callbacks should be received from the
|
|
|
|
// parent channel, nor dequeued from the ChannelEventQueue.
|
|
|
|
bool mFlushedForDiversion;
|
|
|
|
// Set if SendSuspend is called. Determines if SendResume is needed when
|
|
|
|
// diverting callbacks to parent.
|
|
|
|
bool mSuspendSent;
|
2010-08-10 11:47:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
inline bool
|
|
|
|
FTPChannelChild::IsSuspended()
|
|
|
|
{
|
|
|
|
return mSuspendCount != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace net
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_net_FTPChannelChild_h
|