netwerk/protocol/ftp/nsFTPChannel.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/protocol/ftp/nsFTPChannel.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,112 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* vim:set ts=4 sw=4 sts=4 et cindent: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef nsFTPChannel_h___
    1.11 +#define nsFTPChannel_h___
    1.12 +
    1.13 +#include "nsBaseChannel.h"
    1.14 +
    1.15 +#include "nsString.h"
    1.16 +#include "nsCOMPtr.h"
    1.17 +#include "nsIFTPChannel.h"
    1.18 +#include "nsIUploadChannel.h"
    1.19 +#include "nsIProxyInfo.h"
    1.20 +#include "nsIProxiedChannel.h"
    1.21 +#include "nsIResumableChannel.h"
    1.22 +
    1.23 +class nsIURI;
    1.24 +
    1.25 +class nsFtpChannel : public nsBaseChannel,
    1.26 +                     public nsIFTPChannel,
    1.27 +                     public nsIUploadChannel,
    1.28 +                     public nsIResumableChannel,
    1.29 +                     public nsIProxiedChannel
    1.30 +{
    1.31 +public:
    1.32 +    NS_DECL_ISUPPORTS_INHERITED
    1.33 +    NS_DECL_NSIUPLOADCHANNEL
    1.34 +    NS_DECL_NSIRESUMABLECHANNEL
    1.35 +    NS_DECL_NSIPROXIEDCHANNEL
    1.36 +
    1.37 +    nsFtpChannel(nsIURI *uri, nsIProxyInfo *pi)
    1.38 +        : mProxyInfo(pi)
    1.39 +        , mStartPos(0)
    1.40 +        , mResumeRequested(false)
    1.41 +        , mLastModifiedTime(0)
    1.42 +        , mForcePending(false)
    1.43 +    {
    1.44 +        SetURI(uri);
    1.45 +    }
    1.46 +
    1.47 +    nsIProxyInfo *ProxyInfo() {
    1.48 +        return mProxyInfo;
    1.49 +    }
    1.50 +
    1.51 +    void SetProxyInfo(nsIProxyInfo *pi)
    1.52 +    {
    1.53 +        mProxyInfo = pi;
    1.54 +    }
    1.55 +
    1.56 +    NS_IMETHOD IsPending(bool *result) MOZ_OVERRIDE;
    1.57 +
    1.58 +    // This is a short-cut to calling nsIRequest::IsPending().
    1.59 +    // Overrides Pending in nsBaseChannel.
    1.60 +    bool Pending() const MOZ_OVERRIDE;
    1.61 +
    1.62 +    // Were we asked to resume a download?
    1.63 +    bool ResumeRequested() { return mResumeRequested; }
    1.64 +
    1.65 +    // Download from this byte offset
    1.66 +    uint64_t StartPos() { return mStartPos; }
    1.67 +
    1.68 +    // ID of the entity to resume downloading
    1.69 +    const nsCString &EntityID() {
    1.70 +        return mEntityID;
    1.71 +    }
    1.72 +    void SetEntityID(const nsCSubstring &entityID) {
    1.73 +        mEntityID = entityID;
    1.74 +    }
    1.75 +
    1.76 +    NS_IMETHODIMP GetLastModifiedTime(PRTime* lastModifiedTime) {
    1.77 +        *lastModifiedTime = mLastModifiedTime;
    1.78 +        return NS_OK;
    1.79 +    }
    1.80 +
    1.81 +    NS_IMETHODIMP SetLastModifiedTime(PRTime lastModifiedTime) {
    1.82 +        mLastModifiedTime = lastModifiedTime;
    1.83 +        return NS_OK;
    1.84 +    }
    1.85 +
    1.86 +    // Data stream to upload
    1.87 +    nsIInputStream *UploadStream() {
    1.88 +        return mUploadStream;
    1.89 +    }
    1.90 +
    1.91 +    // Helper function for getting the nsIFTPEventSink.
    1.92 +    void GetFTPEventSink(nsCOMPtr<nsIFTPEventSink> &aResult);
    1.93 +
    1.94 +public: /* Internal Necko use only. */
    1.95 +    void ForcePending(bool aForcePending);
    1.96 +
    1.97 +protected:
    1.98 +    virtual ~nsFtpChannel() {}
    1.99 +    virtual nsresult OpenContentStream(bool async, nsIInputStream **result,
   1.100 +                                       nsIChannel** channel);
   1.101 +    virtual bool GetStatusArg(nsresult status, nsString &statusArg);
   1.102 +    virtual void OnCallbacksChanged();
   1.103 +
   1.104 +private:
   1.105 +    nsCOMPtr<nsIProxyInfo>    mProxyInfo; 
   1.106 +    nsCOMPtr<nsIFTPEventSink> mFTPEventSink;
   1.107 +    nsCOMPtr<nsIInputStream>  mUploadStream;
   1.108 +    uint64_t                  mStartPos;
   1.109 +    nsCString                 mEntityID;
   1.110 +    bool                      mResumeRequested;
   1.111 +    PRTime                    mLastModifiedTime;
   1.112 +    bool                      mForcePending;
   1.113 +};
   1.114 +
   1.115 +#endif /* nsFTPChannel_h___ */

mercurial