netwerk/protocol/ftp/nsFtpProtocolHandler.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: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #ifndef nsFtpProtocolHandler_h__
     7 #define nsFtpProtocolHandler_h__
     9 #include "nsFtpControlConnection.h"
    10 #include "nsIProxiedProtocolHandler.h"
    11 #include "nsTArray.h"
    12 #include "nsITimer.h"
    13 #include "nsIObserver.h"
    14 #include "nsWeakReference.h"
    16 class nsICacheSession;
    18 //-----------------------------------------------------------------------------
    20 class nsFtpProtocolHandler : public nsIProxiedProtocolHandler
    21                            , public nsIObserver
    22                            , public nsSupportsWeakReference
    23 {
    24 public:
    25     NS_DECL_THREADSAFE_ISUPPORTS
    26     NS_DECL_NSIPROTOCOLHANDLER
    27     NS_DECL_NSIPROXIEDPROTOCOLHANDLER
    28     NS_DECL_NSIOBSERVER
    30     nsFtpProtocolHandler();
    31     virtual ~nsFtpProtocolHandler();
    33     nsresult Init();
    35     // FTP Connection list access
    36     nsresult InsertConnection(nsIURI *aKey, nsFtpControlConnection *aConn);
    37     nsresult RemoveConnection(nsIURI *aKey, nsFtpControlConnection **aConn);
    38     uint32_t GetSessionId() { return mSessionId; }
    40     uint8_t GetDataQoSBits() { return mDataQoSBits; }
    41     uint8_t GetControlQoSBits() { return mControlQoSBits; }
    43 private:
    44     // Stuff for the timer callback function
    45     struct timerStruct {
    46         nsCOMPtr<nsITimer>      timer;
    47         nsFtpControlConnection *conn;
    48         char                   *key;
    50         timerStruct() : conn(nullptr), key(nullptr) {}
    52         ~timerStruct() {
    53             if (timer)
    54                 timer->Cancel();
    55             if (key)
    56                 nsMemory::Free(key);
    57             if (conn) {
    58                 conn->Disconnect(NS_ERROR_ABORT);
    59                 NS_RELEASE(conn);
    60             }
    61         }
    62     };
    64     static void Timeout(nsITimer *aTimer, void *aClosure);
    65     void ClearAllConnections();
    67     nsTArray<timerStruct*> mRootConnectionList;
    69     nsCOMPtr<nsICacheSession> mCacheSession;
    70     int32_t mIdleTimeout;
    72     // When "clear active logins" is performed, all idle connection are dropped
    73     // and mSessionId is incremented. When nsFtpState wants to insert idle
    74     // connection we refuse to cache if its mSessionId is different (i.e.
    75     // control connection had been created before last "clear active logins" was
    76     // performed.
    77     uint32_t mSessionId;
    79     uint8_t mControlQoSBits;
    80     uint8_t mDataQoSBits;
    81 };
    83 //-----------------------------------------------------------------------------
    85 extern nsFtpProtocolHandler *gFtpHandler;
    87 #ifdef PR_LOGGING
    88 extern PRLogModuleInfo* gFTPLog;
    89 #endif
    91 #endif // !nsFtpProtocolHandler_h__

mercurial