Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* vim:set ts=4 sw=4 sts=4 et cindent: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #ifndef nsFTPChannel_h___ |
michael@0 | 8 | #define nsFTPChannel_h___ |
michael@0 | 9 | |
michael@0 | 10 | #include "nsBaseChannel.h" |
michael@0 | 11 | |
michael@0 | 12 | #include "nsString.h" |
michael@0 | 13 | #include "nsCOMPtr.h" |
michael@0 | 14 | #include "nsIFTPChannel.h" |
michael@0 | 15 | #include "nsIUploadChannel.h" |
michael@0 | 16 | #include "nsIProxyInfo.h" |
michael@0 | 17 | #include "nsIProxiedChannel.h" |
michael@0 | 18 | #include "nsIResumableChannel.h" |
michael@0 | 19 | |
michael@0 | 20 | class nsIURI; |
michael@0 | 21 | |
michael@0 | 22 | class nsFtpChannel : public nsBaseChannel, |
michael@0 | 23 | public nsIFTPChannel, |
michael@0 | 24 | public nsIUploadChannel, |
michael@0 | 25 | public nsIResumableChannel, |
michael@0 | 26 | public nsIProxiedChannel |
michael@0 | 27 | { |
michael@0 | 28 | public: |
michael@0 | 29 | NS_DECL_ISUPPORTS_INHERITED |
michael@0 | 30 | NS_DECL_NSIUPLOADCHANNEL |
michael@0 | 31 | NS_DECL_NSIRESUMABLECHANNEL |
michael@0 | 32 | NS_DECL_NSIPROXIEDCHANNEL |
michael@0 | 33 | |
michael@0 | 34 | nsFtpChannel(nsIURI *uri, nsIProxyInfo *pi) |
michael@0 | 35 | : mProxyInfo(pi) |
michael@0 | 36 | , mStartPos(0) |
michael@0 | 37 | , mResumeRequested(false) |
michael@0 | 38 | , mLastModifiedTime(0) |
michael@0 | 39 | , mForcePending(false) |
michael@0 | 40 | { |
michael@0 | 41 | SetURI(uri); |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | nsIProxyInfo *ProxyInfo() { |
michael@0 | 45 | return mProxyInfo; |
michael@0 | 46 | } |
michael@0 | 47 | |
michael@0 | 48 | void SetProxyInfo(nsIProxyInfo *pi) |
michael@0 | 49 | { |
michael@0 | 50 | mProxyInfo = pi; |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | NS_IMETHOD IsPending(bool *result) MOZ_OVERRIDE; |
michael@0 | 54 | |
michael@0 | 55 | // This is a short-cut to calling nsIRequest::IsPending(). |
michael@0 | 56 | // Overrides Pending in nsBaseChannel. |
michael@0 | 57 | bool Pending() const MOZ_OVERRIDE; |
michael@0 | 58 | |
michael@0 | 59 | // Were we asked to resume a download? |
michael@0 | 60 | bool ResumeRequested() { return mResumeRequested; } |
michael@0 | 61 | |
michael@0 | 62 | // Download from this byte offset |
michael@0 | 63 | uint64_t StartPos() { return mStartPos; } |
michael@0 | 64 | |
michael@0 | 65 | // ID of the entity to resume downloading |
michael@0 | 66 | const nsCString &EntityID() { |
michael@0 | 67 | return mEntityID; |
michael@0 | 68 | } |
michael@0 | 69 | void SetEntityID(const nsCSubstring &entityID) { |
michael@0 | 70 | mEntityID = entityID; |
michael@0 | 71 | } |
michael@0 | 72 | |
michael@0 | 73 | NS_IMETHODIMP GetLastModifiedTime(PRTime* lastModifiedTime) { |
michael@0 | 74 | *lastModifiedTime = mLastModifiedTime; |
michael@0 | 75 | return NS_OK; |
michael@0 | 76 | } |
michael@0 | 77 | |
michael@0 | 78 | NS_IMETHODIMP SetLastModifiedTime(PRTime lastModifiedTime) { |
michael@0 | 79 | mLastModifiedTime = lastModifiedTime; |
michael@0 | 80 | return NS_OK; |
michael@0 | 81 | } |
michael@0 | 82 | |
michael@0 | 83 | // Data stream to upload |
michael@0 | 84 | nsIInputStream *UploadStream() { |
michael@0 | 85 | return mUploadStream; |
michael@0 | 86 | } |
michael@0 | 87 | |
michael@0 | 88 | // Helper function for getting the nsIFTPEventSink. |
michael@0 | 89 | void GetFTPEventSink(nsCOMPtr<nsIFTPEventSink> &aResult); |
michael@0 | 90 | |
michael@0 | 91 | public: /* Internal Necko use only. */ |
michael@0 | 92 | void ForcePending(bool aForcePending); |
michael@0 | 93 | |
michael@0 | 94 | protected: |
michael@0 | 95 | virtual ~nsFtpChannel() {} |
michael@0 | 96 | virtual nsresult OpenContentStream(bool async, nsIInputStream **result, |
michael@0 | 97 | nsIChannel** channel); |
michael@0 | 98 | virtual bool GetStatusArg(nsresult status, nsString &statusArg); |
michael@0 | 99 | virtual void OnCallbacksChanged(); |
michael@0 | 100 | |
michael@0 | 101 | private: |
michael@0 | 102 | nsCOMPtr<nsIProxyInfo> mProxyInfo; |
michael@0 | 103 | nsCOMPtr<nsIFTPEventSink> mFTPEventSink; |
michael@0 | 104 | nsCOMPtr<nsIInputStream> mUploadStream; |
michael@0 | 105 | uint64_t mStartPos; |
michael@0 | 106 | nsCString mEntityID; |
michael@0 | 107 | bool mResumeRequested; |
michael@0 | 108 | PRTime mLastModifiedTime; |
michael@0 | 109 | bool mForcePending; |
michael@0 | 110 | }; |
michael@0 | 111 | |
michael@0 | 112 | #endif /* nsFTPChannel_h___ */ |