netwerk/protocol/ftp/FTPChannelParent.h

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     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_FTPChannelParent_h
     9 #define mozilla_net_FTPChannelParent_h
    11 #include "ADivertableParentChannel.h"
    12 #include "mozilla/net/PFTPChannelParent.h"
    13 #include "mozilla/net/NeckoParent.h"
    14 #include "nsIParentChannel.h"
    15 #include "nsIInterfaceRequestor.h"
    17 class nsFtpChannel;
    18 class nsILoadContext;
    20 namespace mozilla {
    21 namespace net {
    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
    35   FTPChannelParent(nsILoadContext* aLoadContext, PBOverrideStatus aOverrideStatus);
    36   virtual ~FTPChannelParent();
    38   bool Init(const FTPChannelCreationArgs& aOpenArgs);
    40   // ADivertableParentChannel functions.
    41   void DivertTo(nsIStreamListener *aListener) MOZ_OVERRIDE;
    42   nsresult SuspendForDiversion() MOZ_OVERRIDE;
    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();
    49   // Handles calling OnStart/Stop if there are errors during diversion.
    50   // Called asynchronously from FailDiversion.
    51   void NotifyDiversionFailed(nsresult aErrorCode, bool aSkipResume = true);
    53 protected:
    54   // private, supporting function for ADivertableParentChannel.
    55   nsresult ResumeForDiversion();
    57   // Asynchronously calls NotifyDiversionFailed.
    58   void FailDiversion(nsresult aErrorCode, bool aSkipResume = true);
    60   bool DoAsyncOpen(const URIParams& aURI, const uint64_t& aStartPos,
    61                    const nsCString& aEntityID,
    62                    const OptionalInputStreamParams& aUploadStream);
    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);
    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;
    77   virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
    79   nsRefPtr<nsFtpChannel> mChannel;
    81   bool mIPCClosed;
    83   nsCOMPtr<nsILoadContext> mLoadContext;
    85   PBOverrideStatus mPBOverride;
    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;
    99   // Set if we successfully suspended the nsHttpChannel for diversion. Unset
   100   // when we call ResumeForDiversion.
   101   bool mSuspendedForDiversion;
   102 };
   104 } // namespace net
   105 } // namespace mozilla
   107 #endif // mozilla_net_FTPChannelParent_h

mercurial