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