1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/netwerk/base/src/nsServerSocket.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,54 @@ 1.4 +/* vim:set ts=2 sw=2 et cindent: */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef nsServerSocket_h__ 1.10 +#define nsServerSocket_h__ 1.11 + 1.12 +#include "nsASocketHandler.h" 1.13 +#include "nsIServerSocket.h" 1.14 +#include "mozilla/Mutex.h" 1.15 + 1.16 +//----------------------------------------------------------------------------- 1.17 + 1.18 +class nsServerSocket : public nsASocketHandler 1.19 + , public nsIServerSocket 1.20 +{ 1.21 +public: 1.22 + NS_DECL_THREADSAFE_ISUPPORTS 1.23 + NS_DECL_NSISERVERSOCKET 1.24 + 1.25 + // nsASocketHandler methods: 1.26 + virtual void OnSocketReady(PRFileDesc *fd, int16_t outFlags); 1.27 + virtual void OnSocketDetached(PRFileDesc *fd); 1.28 + virtual void IsLocal(bool *aIsLocal); 1.29 + virtual void KeepWhenOffline(bool *aKeepWhenOffline); 1.30 + 1.31 + virtual uint64_t ByteCountSent() { return 0; } 1.32 + virtual uint64_t ByteCountReceived() { return 0; } 1.33 + nsServerSocket(); 1.34 + 1.35 + // This must be public to support older compilers (xlC_r on AIX) 1.36 + virtual ~nsServerSocket(); 1.37 + 1.38 +private: 1.39 + void OnMsgClose(); 1.40 + void OnMsgAttach(); 1.41 + 1.42 + // try attaching our socket (mFD) to the STS's poll list. 1.43 + nsresult TryAttach(); 1.44 + 1.45 + // lock protects access to mListener; so it is not cleared while being used. 1.46 + mozilla::Mutex mLock; 1.47 + PRFileDesc *mFD; 1.48 + PRNetAddr mAddr; 1.49 + nsCOMPtr<nsIServerSocketListener> mListener; 1.50 + nsCOMPtr<nsIEventTarget> mListenerTarget; 1.51 + bool mAttached; 1.52 + bool mKeepWhenOffline; 1.53 +}; 1.54 + 1.55 +//----------------------------------------------------------------------------- 1.56 + 1.57 +#endif // nsServerSocket_h__