netwerk/protocol/ftp/FTPChannelParent.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/protocol/ftp/FTPChannelParent.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,107 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim: set sw=2 ts=8 et tw=80 : */
     1.6 +
     1.7 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.8 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.9 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
    1.10 +
    1.11 +#ifndef mozilla_net_FTPChannelParent_h
    1.12 +#define mozilla_net_FTPChannelParent_h
    1.13 +
    1.14 +#include "ADivertableParentChannel.h"
    1.15 +#include "mozilla/net/PFTPChannelParent.h"
    1.16 +#include "mozilla/net/NeckoParent.h"
    1.17 +#include "nsIParentChannel.h"
    1.18 +#include "nsIInterfaceRequestor.h"
    1.19 +
    1.20 +class nsFtpChannel;
    1.21 +class nsILoadContext;
    1.22 +
    1.23 +namespace mozilla {
    1.24 +namespace net {
    1.25 +
    1.26 +class FTPChannelParent : public PFTPChannelParent
    1.27 +                       , public nsIParentChannel
    1.28 +                       , public nsIInterfaceRequestor
    1.29 +                       , public ADivertableParentChannel
    1.30 +{
    1.31 +public:
    1.32 +  NS_DECL_ISUPPORTS
    1.33 +  NS_DECL_NSIREQUESTOBSERVER
    1.34 +  NS_DECL_NSISTREAMLISTENER
    1.35 +  NS_DECL_NSIPARENTCHANNEL
    1.36 +  NS_DECL_NSIINTERFACEREQUESTOR
    1.37 +
    1.38 +  FTPChannelParent(nsILoadContext* aLoadContext, PBOverrideStatus aOverrideStatus);
    1.39 +  virtual ~FTPChannelParent();
    1.40 +
    1.41 +  bool Init(const FTPChannelCreationArgs& aOpenArgs);
    1.42 +
    1.43 +  // ADivertableParentChannel functions.
    1.44 +  void DivertTo(nsIStreamListener *aListener) MOZ_OVERRIDE;
    1.45 +  nsresult SuspendForDiversion() MOZ_OVERRIDE;
    1.46 +
    1.47 +  // Calls OnStartRequest for "DivertTo" listener, then notifies child channel
    1.48 +  // that it should divert OnDataAvailable and OnStopRequest calls to this
    1.49 +  // parent channel.
    1.50 +  void StartDiversion();
    1.51 +
    1.52 +  // Handles calling OnStart/Stop if there are errors during diversion.
    1.53 +  // Called asynchronously from FailDiversion.
    1.54 +  void NotifyDiversionFailed(nsresult aErrorCode, bool aSkipResume = true);
    1.55 +
    1.56 +protected:
    1.57 +  // private, supporting function for ADivertableParentChannel.
    1.58 +  nsresult ResumeForDiversion();
    1.59 +
    1.60 +  // Asynchronously calls NotifyDiversionFailed.
    1.61 +  void FailDiversion(nsresult aErrorCode, bool aSkipResume = true);
    1.62 +
    1.63 +  bool DoAsyncOpen(const URIParams& aURI, const uint64_t& aStartPos,
    1.64 +                   const nsCString& aEntityID,
    1.65 +                   const OptionalInputStreamParams& aUploadStream);
    1.66 +
    1.67 +  // used to connect redirected-to channel in parent with just created
    1.68 +  // ChildChannel.  Used during HTTP->FTP redirects.
    1.69 +  bool ConnectChannel(const uint32_t& channelId);
    1.70 +
    1.71 +  virtual bool RecvCancel(const nsresult& status) MOZ_OVERRIDE;
    1.72 +  virtual bool RecvSuspend() MOZ_OVERRIDE;
    1.73 +  virtual bool RecvResume() MOZ_OVERRIDE;
    1.74 +  virtual bool RecvDivertOnDataAvailable(const nsCString& data,
    1.75 +                                         const uint64_t& offset,
    1.76 +                                         const uint32_t& count) MOZ_OVERRIDE;
    1.77 +  virtual bool RecvDivertOnStopRequest(const nsresult& statusCode) MOZ_OVERRIDE;
    1.78 +  virtual bool RecvDivertComplete() MOZ_OVERRIDE;
    1.79 +
    1.80 +  virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
    1.81 +
    1.82 +  nsRefPtr<nsFtpChannel> mChannel;
    1.83 +
    1.84 +  bool mIPCClosed;
    1.85 +
    1.86 +  nsCOMPtr<nsILoadContext> mLoadContext;
    1.87 +
    1.88 +  PBOverrideStatus mPBOverride;
    1.89 +
    1.90 +  // If OnStart/OnData/OnStop have been diverted from the child, forward them to
    1.91 +  // this listener.
    1.92 +  nsCOMPtr<nsIStreamListener> mDivertToListener;
    1.93 +  // Set to the canceled status value if the main channel was canceled.
    1.94 +  nsresult mStatus;
    1.95 +  // Once set, no OnStart/OnData/OnStop calls should be accepted; conversely, it
    1.96 +  // must be set when RecvDivertOnData/~DivertOnStop/~DivertComplete are
    1.97 +  // received from the child channel.
    1.98 +  bool mDivertingFromChild;
    1.99 +  // Set if OnStart|StopRequest was called during a diversion from the child.
   1.100 +  bool mDivertedOnStartRequest;
   1.101 +
   1.102 +  // Set if we successfully suspended the nsHttpChannel for diversion. Unset
   1.103 +  // when we call ResumeForDiversion.
   1.104 +  bool mSuspendedForDiversion;
   1.105 +};
   1.106 +
   1.107 +} // namespace net
   1.108 +} // namespace mozilla
   1.109 +
   1.110 +#endif // mozilla_net_FTPChannelParent_h

mercurial