FileHandleWrapper.h (1316B)
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/. */ 6 7 #ifndef _include_gfx_ipc_FileHandleWrapper_h__ 8 #define _include_gfx_ipc_FileHandleWrapper_h__ 9 10 #include "mozilla/UniquePtrExtensions.h" 11 #include "nsISupportsImpl.h" 12 13 namespace IPC { 14 template <typename P> 15 struct ParamTraits; 16 } 17 18 namespace mozilla { 19 namespace gfx { 20 21 // 22 // A class for sharing file handle or shared handle among multiple clients. 23 // 24 // The file handles or the shared handles consume system resources. The class 25 // could reduce the number of shared handles in a process. 26 // 27 class FileHandleWrapper { 28 friend struct IPC::ParamTraits<gfx::FileHandleWrapper*>; 29 30 public: 31 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(FileHandleWrapper); 32 33 explicit FileHandleWrapper(mozilla::UniqueFileHandle&& aHandle); 34 35 mozilla::detail::FileHandleType GetHandle(); 36 37 mozilla::UniqueFileHandle ClonePlatformHandle(); 38 39 protected: 40 ~FileHandleWrapper(); 41 42 const mozilla::UniqueFileHandle mHandle; 43 }; 44 45 } // namespace gfx 46 } // namespace mozilla 47 48 #endif // _include_gfx_ipc_FileHandleWrapper_h__