netwerk/base/src/nsServerSocket.h

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:c8f8f1a8e448
1 /* vim:set ts=2 sw=2 et cindent: */
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 nsServerSocket_h__
7 #define nsServerSocket_h__
8
9 #include "nsASocketHandler.h"
10 #include "nsIServerSocket.h"
11 #include "mozilla/Mutex.h"
12
13 //-----------------------------------------------------------------------------
14
15 class nsServerSocket : public nsASocketHandler
16 , public nsIServerSocket
17 {
18 public:
19 NS_DECL_THREADSAFE_ISUPPORTS
20 NS_DECL_NSISERVERSOCKET
21
22 // nsASocketHandler methods:
23 virtual void OnSocketReady(PRFileDesc *fd, int16_t outFlags);
24 virtual void OnSocketDetached(PRFileDesc *fd);
25 virtual void IsLocal(bool *aIsLocal);
26 virtual void KeepWhenOffline(bool *aKeepWhenOffline);
27
28 virtual uint64_t ByteCountSent() { return 0; }
29 virtual uint64_t ByteCountReceived() { return 0; }
30 nsServerSocket();
31
32 // This must be public to support older compilers (xlC_r on AIX)
33 virtual ~nsServerSocket();
34
35 private:
36 void OnMsgClose();
37 void OnMsgAttach();
38
39 // try attaching our socket (mFD) to the STS's poll list.
40 nsresult TryAttach();
41
42 // lock protects access to mListener; so it is not cleared while being used.
43 mozilla::Mutex mLock;
44 PRFileDesc *mFD;
45 PRNetAddr mAddr;
46 nsCOMPtr<nsIServerSocketListener> mListener;
47 nsCOMPtr<nsIEventTarget> mListenerTarget;
48 bool mAttached;
49 bool mKeepWhenOffline;
50 };
51
52 //-----------------------------------------------------------------------------
53
54 #endif // nsServerSocket_h__

mercurial