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 http://mozilla.org/MPL/2.0/. */
7 #ifndef _include_gfx_ipc_FileHandleWrapper_h__
8 #define _include_gfx_ipc_FileHandleWrapper_h__
10 #include "mozilla/UniquePtrExtensions.h"
11 #include "nsISupportsImpl.h"
17 struct IPDLParamTraits
;
23 // A class for sharing file handle or shared handle among multiple clients.
25 // The file handles or the shared handles consume system resources. The class
26 // could reduce the number of shared handles in a process.
28 class FileHandleWrapper
{
29 friend struct mozilla::ipc::IPDLParamTraits
<gfx::FileHandleWrapper
*>;
32 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(FileHandleWrapper
);
34 explicit FileHandleWrapper(mozilla::UniqueFileHandle
&& aHandle
);
36 mozilla::detail::FileHandleType
GetHandle();
38 mozilla::UniqueFileHandle
ClonePlatformHandle();
43 const mozilla::UniqueFileHandle mHandle
;
47 FenceInfo() = default;
48 FenceInfo(FileHandleWrapper
* aFenceHandle
, uint64_t aFenceValue
)
49 : mFenceHandle(aFenceHandle
), mFenceValue(aFenceValue
) {}
51 bool operator==(const FenceInfo
& aOther
) const {
52 return mFenceHandle
== aOther
.mFenceHandle
&&
53 mFenceValue
== aOther
.mFenceValue
;
56 RefPtr
<FileHandleWrapper
> mFenceHandle
;
57 uint64_t mFenceValue
= 0;
61 } // namespace mozilla
63 #endif // _include_gfx_ipc_FileHandleWrapper_h__