summaryrefslogtreecommitdiffstats
path: root/netwerk/protocol/ftp/FTPChannelParent.h
blob: 21ef7590bb66847332d37c4dd2e42ccb276abe01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set sw=2 ts=8 et tw=80 : */

/* 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/. */

#ifndef mozilla_net_FTPChannelParent_h
#define mozilla_net_FTPChannelParent_h

#include "mozilla/net/PFTPChannelParent.h"
#include "mozilla/net/NeckoParent.h"
#include "nsIParentChannel.h"
#include "nsIInterfaceRequestor.h"
#include "nsIChannelEventSink.h"
#include "nsIFTPChannelParentInternal.h"

class nsILoadContext;

namespace mozilla {

namespace dom {
class BrowserParent;
}  // namespace dom

namespace net {
class ChannelEventQueue;

class FTPChannelParent final : public PFTPChannelParent,
                               public nsIParentChannel,
                               public nsIInterfaceRequestor,
                               public nsIChannelEventSink,
                               public nsIFTPChannelParentInternal {
 public:
  NS_DECL_ISUPPORTS
  NS_DECL_NSIREQUESTOBSERVER
  NS_DECL_NSISTREAMLISTENER
  NS_DECL_NSIPARENTCHANNEL
  NS_DECL_NSIINTERFACEREQUESTOR
  NS_DECL_NSICHANNELEVENTSINK

  FTPChannelParent(dom::BrowserParent* aIframeEmbedding,
                   nsILoadContext* aLoadContext,
                   PBOverrideStatus aOverrideStatus);

  bool Init(const FTPChannelCreationArgs& aOpenArgs);

  NS_IMETHOD SetErrorMsg(const char* aMsg, bool aUseUTF8) override;

 protected:
  virtual ~FTPChannelParent();

  bool DoAsyncOpen(const URIParams& aURI, const uint64_t& aStartPos,
                   const nsCString& aEntityID,
                   const Maybe<IPCStream>& aUploadStream,
                   const Maybe<LoadInfoArgs>& aLoadInfoArgs,
                   const uint32_t& aLoadFlags);

  // used to connect redirected-to channel in parent with just created
  // ChildChannel.  Used during HTTP->FTP redirects.
  bool ConnectChannel(const uint64_t& channelId);

  virtual mozilla::ipc::IPCResult RecvCancel(const nsresult& status) override;
  virtual mozilla::ipc::IPCResult RecvSuspend() override;
  virtual mozilla::ipc::IPCResult RecvResume() override;

  virtual void ActorDestroy(ActorDestroyReason why) override;

  // if configured to use HTTP proxy for FTP, this can an an HTTP channel.
  nsCOMPtr<nsIChannel> mChannel;

  bool mIPCClosed;

  nsCOMPtr<nsILoadContext> mLoadContext;

  PBOverrideStatus mPBOverride;

  // Set to the canceled status value if the main channel was canceled.
  nsresult mStatus;

  RefPtr<mozilla::dom::BrowserParent> mBrowserParent;

  RefPtr<ChannelEventQueue> mEventQ;

  nsCString mErrorMsg;
  bool mUseUTF8;
};

}  // namespace net
}  // namespace mozilla

#endif  // mozilla_net_FTPChannelParent_h