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

mercurial