netwerk/protocol/ftp/FTPChannelChild.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* vim: set sw=2 ts=8 et tw=80 : */
     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/. */
     8 #ifndef mozilla_net_FTPChannelChild_h
     9 #define mozilla_net_FTPChannelChild_h
    11 #include "mozilla/net/PFTPChannelChild.h"
    12 #include "mozilla/net/ChannelEventQueue.h"
    13 #include "nsBaseChannel.h"
    14 #include "nsIFTPChannel.h"
    15 #include "nsIUploadChannel.h"
    16 #include "nsIProxiedChannel.h"
    17 #include "nsIResumableChannel.h"
    18 #include "nsIChildChannel.h"
    19 #include "nsIDivertableChannel.h"
    21 #include "nsIStreamListener.h"
    22 #include "PrivateBrowsingChannel.h"
    24 namespace mozilla {
    25 namespace net {
    27 // This class inherits logic from nsBaseChannel that is not needed for an
    28 // e10s child channel, but it works.  At some point we could slice up
    29 // nsBaseChannel and have a new class that has only the common logic for
    30 // nsFTPChannel/FTPChannelChild.
    32 class FTPChannelChild : public PFTPChannelChild
    33                       , public nsBaseChannel
    34                       , public nsIFTPChannel
    35                       , public nsIUploadChannel
    36                       , public nsIResumableChannel
    37                       , public nsIProxiedChannel
    38                       , public nsIChildChannel
    39                       , public nsIDivertableChannel
    40 {
    41 public:
    42   typedef ::nsIStreamListener nsIStreamListener;
    44   NS_DECL_ISUPPORTS_INHERITED
    45   NS_DECL_NSIFTPCHANNEL
    46   NS_DECL_NSIUPLOADCHANNEL
    47   NS_DECL_NSIRESUMABLECHANNEL
    48   NS_DECL_NSIPROXIEDCHANNEL
    49   NS_DECL_NSICHILDCHANNEL
    50   NS_DECL_NSIDIVERTABLECHANNEL
    52   NS_IMETHOD Cancel(nsresult status);
    53   NS_IMETHOD Suspend();
    54   NS_IMETHOD Resume();
    56   FTPChannelChild(nsIURI* uri);
    57   virtual ~FTPChannelChild();
    59   void AddIPDLReference();
    60   void ReleaseIPDLReference();
    62   NS_IMETHOD AsyncOpen(nsIStreamListener* listener, nsISupports* aContext);
    64   // Note that we handle this ourselves, overriding the nsBaseChannel
    65   // default behavior, in order to be e10s-friendly.
    66   NS_IMETHOD IsPending(bool* result);
    68   nsresult OpenContentStream(bool async,
    69                              nsIInputStream** stream,
    70                              nsIChannel** channel) MOZ_OVERRIDE;
    72   bool IsSuspended();
    74   void FlushedForDiversion();
    76 protected:
    77   bool RecvOnStartRequest(const nsresult& aChannelStatus,
    78                           const int64_t& aContentLength,
    79                           const nsCString& aContentType,
    80                           const PRTime& aLastModified,
    81                           const nsCString& aEntityID,
    82                           const URIParams& aURI) MOZ_OVERRIDE;
    83   bool RecvOnDataAvailable(const nsresult& channelStatus,
    84                            const nsCString& data,
    85                            const uint64_t& offset,
    86                            const uint32_t& count) MOZ_OVERRIDE;
    87   bool RecvOnStopRequest(const nsresult& channelStatus) MOZ_OVERRIDE;
    88   bool RecvFailedAsyncOpen(const nsresult& statusCode) MOZ_OVERRIDE;
    89   bool RecvFlushedForDiversion() MOZ_OVERRIDE;
    90   bool RecvDivertMessages() MOZ_OVERRIDE;
    91   bool RecvDeleteSelf() MOZ_OVERRIDE;
    93   void DoOnStartRequest(const nsresult& aChannelStatus,
    94                         const int64_t& aContentLength,
    95                         const nsCString& aContentType,
    96                         const PRTime& aLastModified,
    97                         const nsCString& aEntityID,
    98                         const URIParams& aURI);
    99   void DoOnDataAvailable(const nsresult& channelStatus,
   100                          const nsCString& data,
   101                          const uint64_t& offset,
   102                          const uint32_t& count);
   103   void DoOnStopRequest(const nsresult& statusCode);
   104   void DoFailedAsyncOpen(const nsresult& statusCode);
   105   void DoDeleteSelf();
   107   friend class FTPStartRequestEvent;
   108   friend class FTPDataAvailableEvent;
   109   friend class FTPStopRequestEvent;
   110   friend class FTPFailedAsyncOpenEvent;
   111   friend class FTPDeleteSelfEvent;
   113 private:
   114   nsCOMPtr<nsIInputStream> mUploadStream;
   116   bool mIPCOpen;
   117   nsRefPtr<ChannelEventQueue> mEventQ;
   118   bool mCanceled;
   119   uint32_t mSuspendCount;
   120   bool mIsPending;
   121   bool mWasOpened;
   123   PRTime mLastModifiedTime;
   124   uint64_t mStartPos;
   125   nsCString mEntityID;
   127   // Once set, OnData and possibly OnStop will be diverted to the parent.
   128   bool mDivertingToParent;
   129   // Once set, no OnStart/OnData/OnStop callbacks should be received from the
   130   // parent channel, nor dequeued from the ChannelEventQueue.
   131   bool mFlushedForDiversion;
   132   // Set if SendSuspend is called. Determines if SendResume is needed when
   133   // diverting callbacks to parent.
   134   bool mSuspendSent;
   135 };
   137 inline bool
   138 FTPChannelChild::IsSuspended()
   139 {
   140   return mSuspendCount != 0;
   141 }
   143 } // namespace net
   144 } // namespace mozilla
   146 #endif // mozilla_net_FTPChannelChild_h

mercurial