xref: /aosp_15_r20/external/cronet/base/fuchsia/koid.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2021 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef BASE_FUCHSIA_KOID_H_
6 #define BASE_FUCHSIA_KOID_H_
7 
8 #include <lib/zx/object.h>
9 #include <zircon/types.h>
10 
11 #include <optional>
12 
13 #include "base/base_export.h"
14 
15 namespace base {
16 
17 // Returns the Kernel Object IDentifier for the object referred to by |handle|,
18 // if it is valid.
19 BASE_EXPORT std::optional<zx_koid_t> GetKoid(const zx::object_base& handle);
20 
21 // Returns the Kernel Object IDentifier for the peer of the paired object (i.e.
22 // a channel, socket, eventpair, etc) referred to by |handle|.
23 BASE_EXPORT std::optional<zx_koid_t> GetRelatedKoid(
24     const zx::object_base& handle);
25 
26 }  // namespace base
27 
28 #endif  // BASE_FUCHSIA_KOID_H_
29