Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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__