2010-08-10 22:47:00 +04: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 15:12:37 +04: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 22:47:00 +04: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-24 01:56:06 +03:00
|
|
|
#include "nsIChildChannel.h"
|
2014-03-11 02:04:28 +04:00
|
|
|
#include "nsIDivertableChannel.h"
|
2010-08-10 22:47:00 +04:00
|
|
|
|
|
|
|
#include "nsIStreamListener.h"
|
2012-09-05 04:37:45 +04:00
|
|
|
#include "PrivateBrowsingChannel.h"
|
2010-08-10 22:47:00 +04: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-24 01:56:06 +03:00
|
|
|
, public nsIChildChannel
|
2014-03-11 02:04:28 +04:00
|
|
|
, public nsIDivertableChannel
|
2010-08-10 22:47:00 +04:00
|
|
|
{
|
|
|
|
public:
|
2010-11-24 01:56:06 +03:00
|
|
|
typedef ::nsIStreamListener nsIStreamListener;
|
|
|
|
|
2010-08-10 22:47:00 +04:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_NSIFTPCHANNEL
|
|
|
|
NS_DECL_NSIUPLOADCHANNEL
|
|
|
|
NS_DECL_NSIRESUMABLECHANNEL
|
|
|
|
NS_DECL_NSIPROXIEDCHANNEL
|
2010-11-24 01:56:06 +03:00
|
|
|
NS_DECL_NSICHILDCHANNEL
|
2014-03-11 02:04:28 +04:00
|
|
|
NS_DECL_NSIDIVERTABLECHANNEL
|
2010-08-10 22:47:00 +04:00
|
|
|
|
|
|
|
NS_IMETHOD Cancel(nsresult status);
|
|
|
|
NS_IMETHOD Suspend();
|
|
|
|
NS_IMETHOD Resume();
|
|
|
|
|
|
|
|
FTPChannelChild(nsIURI* uri);
|
|
|
|
virtual ~FTPChannelChild();
|
|
|
|
|
|
|
|
void AddIPDLReference();
|
|
|
|
void ReleaseIPDLReference();
|
|
|
|
|
2010-11-24 01:56:06 +03:00
|
|
|
NS_IMETHOD AsyncOpen(nsIStreamListener* listener, nsISupports* aContext);
|
2010-08-10 22:47:00 +04:00
|
|
|
|
|
|
|
// Note that we handle this ourselves, overriding the nsBaseChannel
|
|
|
|
// default behavior, in order to be e10s-friendly.
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHOD IsPending(bool* result);
|
2010-08-10 22:47:00 +04:00
|
|
|
|
2012-07-06 22:15:45 +04:00
|
|
|
nsresult OpenContentStream(bool async,
|
|
|
|
nsIInputStream** stream,
|
|
|
|
nsIChannel** channel) MOZ_OVERRIDE;
|
2010-08-10 22:47:00 +04:00
|
|
|
|
|
|
|
bool IsSuspended();
|
|
|
|
|
2014-03-11 02:04:28 +04:00
|
|
|
void FlushedForDiversion();
|
|
|
|
|
2010-08-10 22:47:00 +04:00
|
|
|
protected:
|
2012-10-22 21:51:07 +04:00
|
|
|
bool RecvOnStartRequest(const int64_t& aContentLength,
|
2012-07-06 22:15:45 +04:00
|
|
|
const nsCString& aContentType,
|
|
|
|
const PRTime& aLastModified,
|
|
|
|
const nsCString& aEntityID,
|
2012-08-23 23:33:46 +04:00
|
|
|
const URIParams& aURI) MOZ_OVERRIDE;
|
2012-07-06 22:15:45 +04:00
|
|
|
bool RecvOnDataAvailable(const nsCString& data,
|
2012-09-06 06:41:02 +04:00
|
|
|
const uint64_t& offset,
|
2012-08-22 19:56:38 +04:00
|
|
|
const uint32_t& count) MOZ_OVERRIDE;
|
2012-07-06 22:15:45 +04:00
|
|
|
bool RecvOnStopRequest(const nsresult& statusCode) MOZ_OVERRIDE;
|
|
|
|
bool RecvFailedAsyncOpen(const nsresult& statusCode) MOZ_OVERRIDE;
|
2014-03-11 02:04:28 +04:00
|
|
|
bool RecvFlushedForDiversion() MOZ_OVERRIDE;
|
|
|
|
bool RecvDivertMessages() MOZ_OVERRIDE;
|
2012-07-06 22:15:45 +04:00
|
|
|
bool RecvDeleteSelf() MOZ_OVERRIDE;
|
2010-08-10 22:47:00 +04:00
|
|
|
|
2012-10-22 21:51:07 +04:00
|
|
|
void DoOnStartRequest(const int64_t& aContentLength,
|
2010-08-10 22:47:00 +04:00
|
|
|
const nsCString& aContentType,
|
|
|
|
const PRTime& aLastModified,
|
|
|
|
const nsCString& aEntityID,
|
2012-08-23 23:33:46 +04:00
|
|
|
const URIParams& aURI);
|
2010-08-10 22:47:00 +04:00
|
|
|
void DoOnDataAvailable(const nsCString& data,
|
2012-09-06 06:41:02 +04:00
|
|
|
const uint64_t& offset,
|
2012-08-22 19:56:38 +04:00
|
|
|
const uint32_t& count);
|
2010-08-10 22:47:00 +04:00
|
|
|
void DoOnStopRequest(const nsresult& statusCode);
|
2012-01-11 11:19:17 +04:00
|
|
|
void DoFailedAsyncOpen(const nsresult& statusCode);
|
2010-11-24 01:56:06 +03:00
|
|
|
void DoDeleteSelf();
|
2010-08-10 22:47:00 +04:00
|
|
|
|
|
|
|
friend class FTPStartRequestEvent;
|
|
|
|
friend class FTPDataAvailableEvent;
|
|
|
|
friend class FTPStopRequestEvent;
|
2012-01-11 11:19:17 +04:00
|
|
|
friend class FTPFailedAsyncOpenEvent;
|
2010-11-24 01:56:06 +03:00
|
|
|
friend class FTPDeleteSelfEvent;
|
2010-08-10 22:47:00 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
nsCOMPtr<nsIInputStream> mUploadStream;
|
|
|
|
|
|
|
|
bool mIPCOpen;
|
2013-06-05 03:10:55 +04:00
|
|
|
nsRefPtr<ChannelEventQueue> mEventQ;
|
2010-08-10 22:47:00 +04:00
|
|
|
bool mCanceled;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mSuspendCount;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mIsPending;
|
|
|
|
bool mWasOpened;
|
2010-08-10 22:47:00 +04:00
|
|
|
|
|
|
|
PRTime mLastModifiedTime;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t mStartPos;
|
2010-08-10 22:47:00 +04:00
|
|
|
nsCString mEntityID;
|
2014-03-11 02:04:28 +04: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 22:47:00 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
inline bool
|
|
|
|
FTPChannelChild::IsSuspended()
|
|
|
|
{
|
|
|
|
return mSuspendCount != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace net
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_net_FTPChannelChild_h
|