/src/mozilla-central/netwerk/protocol/ftp/nsFtpProtocolHandler.h
Line | Count | Source (jump to first uncovered line) |
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/. */ |
5 | | |
6 | | #ifndef nsFtpProtocolHandler_h__ |
7 | | #define nsFtpProtocolHandler_h__ |
8 | | |
9 | | #include "nsFtpControlConnection.h" |
10 | | #include "nsIProxiedProtocolHandler.h" |
11 | | #include "nsTArray.h" |
12 | | #include "nsITimer.h" |
13 | | #include "nsIObserver.h" |
14 | | #include "nsWeakReference.h" |
15 | | |
16 | | //----------------------------------------------------------------------------- |
17 | | |
18 | | class nsFtpProtocolHandler final : public nsIProxiedProtocolHandler |
19 | | , public nsIObserver |
20 | | , public nsSupportsWeakReference |
21 | | { |
22 | | public: |
23 | | NS_DECL_THREADSAFE_ISUPPORTS |
24 | | NS_DECL_NSIPROTOCOLHANDLER |
25 | | NS_DECL_NSIPROXIEDPROTOCOLHANDLER |
26 | | NS_DECL_NSIOBSERVER |
27 | | |
28 | | nsFtpProtocolHandler(); |
29 | | |
30 | | nsresult Init(); |
31 | | |
32 | | // FTP Connection list access |
33 | | nsresult InsertConnection(nsIURI *aKey, nsFtpControlConnection *aConn); |
34 | | nsresult RemoveConnection(nsIURI *aKey, nsFtpControlConnection **aConn); |
35 | 0 | uint32_t GetSessionId() { return mSessionId; } |
36 | | |
37 | 0 | uint8_t GetDataQoSBits() { return mDataQoSBits; } |
38 | 0 | uint8_t GetControlQoSBits() { return mControlQoSBits; } |
39 | | |
40 | | private: |
41 | | virtual ~nsFtpProtocolHandler(); |
42 | | |
43 | | // Stuff for the timer callback function |
44 | | struct timerStruct { |
45 | | nsCOMPtr<nsITimer> timer; |
46 | | RefPtr<nsFtpControlConnection> conn; |
47 | | char *key; |
48 | | |
49 | 0 | timerStruct() : key(nullptr) {} |
50 | | |
51 | 0 | ~timerStruct() { |
52 | 0 | if (timer) |
53 | 0 | timer->Cancel(); |
54 | 0 | if (key) |
55 | 0 | free(key); |
56 | 0 | if (conn) { |
57 | 0 | conn->Disconnect(NS_ERROR_ABORT); |
58 | 0 | } |
59 | 0 | } |
60 | | }; |
61 | | |
62 | | static void Timeout(nsITimer *aTimer, void *aClosure); |
63 | | void ClearAllConnections(); |
64 | | |
65 | | nsTArray<timerStruct*> mRootConnectionList; |
66 | | |
67 | | int32_t mIdleTimeout; |
68 | | bool mEnabled; |
69 | | |
70 | | // When "clear active logins" is performed, all idle connection are dropped |
71 | | // and mSessionId is incremented. When nsFtpState wants to insert idle |
72 | | // connection we refuse to cache if its mSessionId is different (i.e. |
73 | | // control connection had been created before last "clear active logins" was |
74 | | // performed. |
75 | | uint32_t mSessionId; |
76 | | |
77 | | uint8_t mControlQoSBits; |
78 | | uint8_t mDataQoSBits; |
79 | | }; |
80 | | |
81 | | //----------------------------------------------------------------------------- |
82 | | |
83 | | extern nsFtpProtocolHandler *gFtpHandler; |
84 | | |
85 | | #include "mozilla/Logging.h" |
86 | | extern mozilla::LazyLogModule gFTPLog; |
87 | | |
88 | | #endif // !nsFtpProtocolHandler_h__ |