Bug 1890689 accumulate input in LargerReceiverBlockSizeThanDesiredBuffering GTest...
[gecko.git] / gfx / ipc / FileHandleWrapper.h
blob6ca905bd617d13ff0ce0be47fd7781850e8b8a7d
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"
13 namespace mozilla {
15 namespace ipc {
16 template <typename T>
17 struct IPDLParamTraits;
18 } // namespace ipc
20 namespace gfx {
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*>;
31 public:
32 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(FileHandleWrapper);
34 explicit FileHandleWrapper(mozilla::UniqueFileHandle&& aHandle);
36 mozilla::detail::FileHandleType GetHandle();
38 mozilla::UniqueFileHandle ClonePlatformHandle();
40 protected:
41 ~FileHandleWrapper();
43 const mozilla::UniqueFileHandle mHandle;
46 struct FenceInfo {
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;
60 } // namespace gfx
61 } // namespace mozilla
63 #endif // _include_gfx_ipc_FileHandleWrapper_h__