netwerk/protocol/ftp/nsFtpProtocolHandler.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/protocol/ftp/nsFtpProtocolHandler.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,91 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef nsFtpProtocolHandler_h__
    1.10 +#define nsFtpProtocolHandler_h__
    1.11 +
    1.12 +#include "nsFtpControlConnection.h"
    1.13 +#include "nsIProxiedProtocolHandler.h"
    1.14 +#include "nsTArray.h"
    1.15 +#include "nsITimer.h"
    1.16 +#include "nsIObserver.h"
    1.17 +#include "nsWeakReference.h"
    1.18 +
    1.19 +class nsICacheSession;
    1.20 +
    1.21 +//-----------------------------------------------------------------------------
    1.22 +
    1.23 +class nsFtpProtocolHandler : public nsIProxiedProtocolHandler
    1.24 +                           , public nsIObserver
    1.25 +                           , public nsSupportsWeakReference
    1.26 +{
    1.27 +public:
    1.28 +    NS_DECL_THREADSAFE_ISUPPORTS
    1.29 +    NS_DECL_NSIPROTOCOLHANDLER
    1.30 +    NS_DECL_NSIPROXIEDPROTOCOLHANDLER
    1.31 +    NS_DECL_NSIOBSERVER
    1.32 +    
    1.33 +    nsFtpProtocolHandler();
    1.34 +    virtual ~nsFtpProtocolHandler();
    1.35 +    
    1.36 +    nsresult Init();
    1.37 +
    1.38 +    // FTP Connection list access
    1.39 +    nsresult InsertConnection(nsIURI *aKey, nsFtpControlConnection *aConn);
    1.40 +    nsresult RemoveConnection(nsIURI *aKey, nsFtpControlConnection **aConn);
    1.41 +    uint32_t GetSessionId() { return mSessionId; }
    1.42 +
    1.43 +    uint8_t GetDataQoSBits() { return mDataQoSBits; }
    1.44 +    uint8_t GetControlQoSBits() { return mControlQoSBits; }
    1.45 +
    1.46 +private:
    1.47 +    // Stuff for the timer callback function
    1.48 +    struct timerStruct {
    1.49 +        nsCOMPtr<nsITimer>      timer;
    1.50 +        nsFtpControlConnection *conn;
    1.51 +        char                   *key;
    1.52 +        
    1.53 +        timerStruct() : conn(nullptr), key(nullptr) {}
    1.54 +        
    1.55 +        ~timerStruct() {
    1.56 +            if (timer)
    1.57 +                timer->Cancel();
    1.58 +            if (key)
    1.59 +                nsMemory::Free(key);
    1.60 +            if (conn) {
    1.61 +                conn->Disconnect(NS_ERROR_ABORT);
    1.62 +                NS_RELEASE(conn);
    1.63 +            }
    1.64 +        }
    1.65 +    };
    1.66 +
    1.67 +    static void Timeout(nsITimer *aTimer, void *aClosure);
    1.68 +    void ClearAllConnections();
    1.69 +
    1.70 +    nsTArray<timerStruct*> mRootConnectionList;
    1.71 +
    1.72 +    nsCOMPtr<nsICacheSession> mCacheSession;
    1.73 +    int32_t mIdleTimeout;
    1.74 +
    1.75 +    // When "clear active logins" is performed, all idle connection are dropped
    1.76 +    // and mSessionId is incremented. When nsFtpState wants to insert idle
    1.77 +    // connection we refuse to cache if its mSessionId is different (i.e.
    1.78 +    // control connection had been created before last "clear active logins" was
    1.79 +    // performed.
    1.80 +    uint32_t mSessionId;
    1.81 +
    1.82 +    uint8_t mControlQoSBits;
    1.83 +    uint8_t mDataQoSBits;
    1.84 +};
    1.85 +
    1.86 +//-----------------------------------------------------------------------------
    1.87 +
    1.88 +extern nsFtpProtocolHandler *gFtpHandler;
    1.89 +
    1.90 +#ifdef PR_LOGGING
    1.91 +extern PRLogModuleInfo* gFTPLog;
    1.92 +#endif
    1.93 +
    1.94 +#endif // !nsFtpProtocolHandler_h__

mercurial