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.)

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

mercurial