michael@0: /* vim:set ts=2 sw=2 et cindent: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsServerSocket_h__ michael@0: #define nsServerSocket_h__ michael@0: michael@0: #include "nsASocketHandler.h" michael@0: #include "nsIServerSocket.h" michael@0: #include "mozilla/Mutex.h" michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: michael@0: class nsServerSocket : public nsASocketHandler michael@0: , public nsIServerSocket michael@0: { michael@0: public: michael@0: NS_DECL_THREADSAFE_ISUPPORTS michael@0: NS_DECL_NSISERVERSOCKET michael@0: michael@0: // nsASocketHandler methods: michael@0: virtual void OnSocketReady(PRFileDesc *fd, int16_t outFlags); michael@0: virtual void OnSocketDetached(PRFileDesc *fd); michael@0: virtual void IsLocal(bool *aIsLocal); michael@0: virtual void KeepWhenOffline(bool *aKeepWhenOffline); michael@0: michael@0: virtual uint64_t ByteCountSent() { return 0; } michael@0: virtual uint64_t ByteCountReceived() { return 0; } michael@0: nsServerSocket(); michael@0: michael@0: // This must be public to support older compilers (xlC_r on AIX) michael@0: virtual ~nsServerSocket(); michael@0: michael@0: private: michael@0: void OnMsgClose(); michael@0: void OnMsgAttach(); michael@0: michael@0: // try attaching our socket (mFD) to the STS's poll list. michael@0: nsresult TryAttach(); michael@0: michael@0: // lock protects access to mListener; so it is not cleared while being used. michael@0: mozilla::Mutex mLock; michael@0: PRFileDesc *mFD; michael@0: PRNetAddr mAddr; michael@0: nsCOMPtr mListener; michael@0: nsCOMPtr mListenerTarget; michael@0: bool mAttached; michael@0: bool mKeepWhenOffline; michael@0: }; michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: michael@0: #endif // nsServerSocket_h__