2003-11-15 03:13:59 +03:00
|
|
|
/* vim:set ts=2 sw=2 et cindent: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2003-11-15 03:13:59 +03:00
|
|
|
|
|
|
|
#ifndef nsServerSocket_h__
|
|
|
|
#define nsServerSocket_h__
|
|
|
|
|
2014-09-19 19:25:00 +04:00
|
|
|
#include "prio.h"
|
2013-09-22 07:04:57 +04:00
|
|
|
#include "nsASocketHandler.h"
|
2003-11-15 03:13:59 +03:00
|
|
|
#include "nsIServerSocket.h"
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-04-01 08:29:02 +04:00
|
|
|
#include "mozilla/Mutex.h"
|
2003-11-15 03:13:59 +03:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2014-09-19 19:25:00 +04:00
|
|
|
class nsIEventTarget;
|
|
|
|
namespace mozilla {
|
|
|
|
namespace net {
|
|
|
|
union NetAddr;
|
|
|
|
|
2003-11-15 03:13:59 +03:00
|
|
|
class nsServerSocket : public nsASocketHandler, public nsIServerSocket {
|
|
|
|
public:
|
2013-07-19 06:24:13 +04:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2003-11-15 03:13:59 +03:00
|
|
|
NS_DECL_NSISERVERSOCKET
|
|
|
|
|
|
|
|
// nsASocketHandler methods:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void OnSocketReady(PRFileDesc *fd, int16_t outFlags) override;
|
|
|
|
virtual void OnSocketDetached(PRFileDesc *fd) override;
|
|
|
|
virtual void IsLocal(bool *aIsLocal) override;
|
|
|
|
virtual void KeepWhenOffline(bool *aKeepWhenOffline) override;
|
2003-11-15 03:13:59 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual uint64_t ByteCountSent() override { return 0; }
|
|
|
|
virtual uint64_t ByteCountReceived() override { return 0; }
|
2003-11-15 03:13:59 +03:00
|
|
|
nsServerSocket();
|
|
|
|
|
2014-09-19 19:25:00 +04:00
|
|
|
virtual void CreateClientTransport(PRFileDesc *clientFD,
|
|
|
|
const mozilla::net::NetAddr &clientAddr);
|
|
|
|
virtual nsresult SetSocketDefaults() { return NS_OK; }
|
|
|
|
virtual nsresult OnSocketListen() { return NS_OK; }
|
|
|
|
|
|
|
|
protected:
|
2003-11-15 03:13:59 +03:00
|
|
|
virtual ~nsServerSocket();
|
2014-09-19 19:25:00 +04:00
|
|
|
PRFileDesc *mFD;
|
|
|
|
nsCOMPtr<nsIServerSocketListener> mListener;
|
2003-11-15 03:13:59 +03:00
|
|
|
|
2014-09-19 19:25:00 +04:00
|
|
|
private:
|
2003-11-15 03:13:59 +03:00
|
|
|
void OnMsgClose();
|
|
|
|
void OnMsgAttach();
|
2014-09-19 19:25:00 +04:00
|
|
|
|
2003-11-15 03:13:59 +03:00
|
|
|
// try attaching our socket (mFD) to the STS's poll list.
|
|
|
|
nsresult TryAttach();
|
|
|
|
|
|
|
|
// lock protects access to mListener; so it is not cleared while being used.
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-04-01 08:29:02 +04:00
|
|
|
mozilla::Mutex mLock;
|
2003-11-15 03:13:59 +03:00
|
|
|
PRNetAddr mAddr;
|
2006-05-11 02:49:04 +04:00
|
|
|
nsCOMPtr<nsIEventTarget> mListenerTarget;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mAttached;
|
2013-03-27 05:22:40 +04:00
|
|
|
bool mKeepWhenOffline;
|
2003-11-15 03:13:59 +03:00
|
|
|
};
|
|
|
|
|
2016-05-19 05:02:57 +03:00
|
|
|
} // namespace net
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2003-11-15 03:13:59 +03:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#endif // nsServerSocket_h__
|