Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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/. */
6 #ifndef nsServerSocket_h__
7 #define nsServerSocket_h__
9 #include "nsASocketHandler.h"
10 #include "nsIServerSocket.h"
11 #include "mozilla/Mutex.h"
13 //-----------------------------------------------------------------------------
15 class nsServerSocket : public nsASocketHandler
16 , public nsIServerSocket
17 {
18 public:
19 NS_DECL_THREADSAFE_ISUPPORTS
20 NS_DECL_NSISERVERSOCKET
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);
28 virtual uint64_t ByteCountSent() { return 0; }
29 virtual uint64_t ByteCountReceived() { return 0; }
30 nsServerSocket();
32 // This must be public to support older compilers (xlC_r on AIX)
33 virtual ~nsServerSocket();
35 private:
36 void OnMsgClose();
37 void OnMsgAttach();
39 // try attaching our socket (mFD) to the STS's poll list.
40 nsresult TryAttach();
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 };
52 //-----------------------------------------------------------------------------
54 #endif // nsServerSocket_h__