Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/dom/TCPServerSocket.h
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5
 * You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#ifndef mozilla_dom_TCPServerSocket_h
8
#define mozilla_dom_TCPServerSocket_h
9
10
#include "mozilla/DOMEventTargetHelper.h"
11
#include "nsIServerSocket.h"
12
13
namespace mozilla {
14
class ErrorResult;
15
namespace dom {
16
17
struct ServerSocketOptions;
18
class GlobalObject;
19
class TCPSocket;
20
class TCPSocketChild;
21
class TCPServerSocketChild;
22
class TCPServerSocketParent;
23
24
class TCPServerSocket final : public DOMEventTargetHelper
25
                            , public nsIServerSocketListener
26
{
27
public:
28
  TCPServerSocket(nsIGlobalObject* aGlobal, uint16_t aPort, bool aUseArrayBuffers,
29
                  uint16_t aBacklog);
30
31
  NS_DECL_ISUPPORTS_INHERITED
32
  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(TCPServerSocket, DOMEventTargetHelper)
33
  NS_DECL_NSISERVERSOCKETLISTENER
34
35
  nsPIDOMWindowInner* GetParentObject() const
36
0
  {
37
0
    return GetOwner();
38
0
  }
39
40
  virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
41
42
  nsresult Init();
43
44
  uint16_t LocalPort();
45
  void Close();
46
47
  static already_AddRefed<TCPServerSocket>
48
  Constructor(const GlobalObject& aGlobal,
49
              uint16_t aPort,
50
              const ServerSocketOptions& aOptions,
51
              uint16_t aBacklog,
52
              mozilla::ErrorResult& aRv);
53
54
  IMPL_EVENT_HANDLER(connect);
55
  IMPL_EVENT_HANDLER(error);
56
57
  // Relay an accepted socket notification from the parent process and
58
  // initialize this object with an existing child actor for the new socket.
59
  nsresult AcceptChildSocket(TCPSocketChild* aSocketChild);
60
  // Associate this object with an IPC actor in the parent process to relay
61
  // notifications to content processes.
62
  void SetServerBridgeParent(TCPServerSocketParent* aBridgeParent);
63
64
private:
65
  ~TCPServerSocket();
66
  // Dispatch a TCPServerSocketEvent event of a given type at this object.
67
  void FireEvent(const nsAString& aType, TCPSocket* aSocket);
68
69
  // The server socket associated with this object.
70
  nsCOMPtr<nsIServerSocket> mServerSocket;
71
  // The IPC actor in the content process.
72
  RefPtr<TCPServerSocketChild> mServerBridgeChild;
73
  // The IPC actor in the parent process.
74
  RefPtr<TCPServerSocketParent> mServerBridgeParent;
75
  int32_t mPort;
76
  uint16_t mBacklog;
77
  // True if any accepted sockets should use array buffers for received messages.
78
  bool mUseArrayBuffers;
79
};
80
81
} // namespace dom
82
} // namespace mozilla
83
84
#endif // mozilla_dom_TCPServerSocket_h