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
5 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_ipc_RawEndpoint_h
8 #define mozilla_ipc_RawEndpoint_h
10 #include "mojo/core/ports/port_ref.h"
12 namespace mozilla::ipc
{
16 /// A uniquely owned raw IPC endpoint, connected to our peers over the node
17 /// controller. This type can be sent over IPC channels to establish
20 /// In general, prefer using Endpoint over ScopedPort for type safety reasons.
22 using PortName
= mojo::core::ports::PortName
;
23 using PortRef
= mojo::core::ports::PortRef
;
29 ScopedPort(PortRef aPort
, NodeController
* aController
);
31 ScopedPort(ScopedPort
&& aOther
);
32 ScopedPort(const ScopedPort
&) = delete;
34 ScopedPort
& operator=(ScopedPort
&& aOther
);
35 ScopedPort
& operator=(const ScopedPort
&) = delete;
37 // Allow checking if this `ScopedPort` is valid or not.
38 bool IsValid() const { return mValid
; }
39 explicit operator bool() const { return IsValid(); }
41 // Underlying port and controller which are used by this ScopedPort.
42 const PortName
& Name() const { return mPort
.name(); }
43 const PortRef
& Port() const { return mPort
; }
44 NodeController
* Controller() const { return mController
; }
46 // Release ownership over the contained `ScopedPort`, meaning that it will
47 // not be closed when this ScopedPort is destroyed. This will make the
56 RefPtr
<NodeController
> mController
;
58 // NOTE: This type does not contain PID information about the other process,
59 // which will need to be sent separately if necessary.
62 } // namespace mozilla::ipc
70 struct ParamTraits
<mozilla::ipc::ScopedPort
> {
71 using paramType
= mozilla::ipc::ScopedPort
;
73 static void Write(MessageWriter
* aWriter
, paramType
&& aParam
);
74 static bool Read(MessageReader
* aReader
, paramType
* aResult
);