Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/netwerk/base/nsServerSocket.h
Line
Count
Source (jump to first uncovered line)
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/. */
5
6
#ifndef nsServerSocket_h__
7
#define nsServerSocket_h__
8
9
#include "prio.h"
10
#include "nsASocketHandler.h"
11
#include "nsIServerSocket.h"
12
#include "mozilla/Mutex.h"
13
14
//-----------------------------------------------------------------------------
15
16
class nsIEventTarget;
17
namespace mozilla { namespace net {
18
union NetAddr;
19
20
class nsServerSocket : public nsASocketHandler
21
                     , public nsIServerSocket
22
{
23
public:
24
  NS_DECL_THREADSAFE_ISUPPORTS
25
  NS_DECL_NSISERVERSOCKET
26
27
  // nsASocketHandler methods:
28
  virtual void OnSocketReady(PRFileDesc *fd, int16_t outFlags) override;
29
  virtual void OnSocketDetached(PRFileDesc *fd) override;
30
  virtual void IsLocal(bool *aIsLocal) override;
31
  virtual void KeepWhenOffline(bool *aKeepWhenOffline) override;
32
33
0
  virtual uint64_t ByteCountSent() override { return 0; }
34
0
  virtual uint64_t ByteCountReceived() override { return 0; }
35
  nsServerSocket();
36
37
  virtual void CreateClientTransport(PRFileDesc* clientFD,
38
                                     const mozilla::net::NetAddr& clientAddr);
39
0
  virtual nsresult SetSocketDefaults() { return NS_OK; }
40
0
  virtual nsresult OnSocketListen() { return NS_OK; }
41
42
protected:
43
  virtual ~nsServerSocket();
44
  PRFileDesc*                       mFD;
45
  nsCOMPtr<nsIServerSocketListener> mListener;
46
47
private:
48
  void OnMsgClose();
49
  void OnMsgAttach();
50
51
  // try attaching our socket (mFD) to the STS's poll list.
52
  nsresult TryAttach();
53
54
  // lock protects access to mListener; so it is not cleared while being used.
55
  mozilla::Mutex                    mLock;
56
  PRNetAddr                         mAddr;
57
  nsCOMPtr<nsIEventTarget>          mListenerTarget;
58
  bool                              mAttached;
59
  bool                              mKeepWhenOffline;
60
};
61
62
} // namespace net
63
} // namespace mozilla
64
65
//-----------------------------------------------------------------------------
66
67
#endif // nsServerSocket_h__