michael@0: michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_ipc_FileDescriptorUtils_h michael@0: #define mozilla_ipc_FileDescriptorUtils_h michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "mozilla/ipc/FileDescriptor.h" michael@0: #include "nsIRunnable.h" michael@0: michael@0: namespace mozilla { michael@0: namespace ipc { michael@0: michael@0: // When Dispatch() is called (from main thread) this class arranges to close the michael@0: // provided FileDescriptor on one of the socket transport service threads (to michael@0: // avoid main thread I/O). michael@0: class CloseFileRunnable MOZ_FINAL : public nsIRunnable michael@0: { michael@0: typedef mozilla::ipc::FileDescriptor FileDescriptor; michael@0: michael@0: FileDescriptor mFileDescriptor; michael@0: michael@0: public: michael@0: CloseFileRunnable(const FileDescriptor& aFileDescriptor) michael@0: #ifdef DEBUG michael@0: ; michael@0: #else michael@0: : mFileDescriptor(aFileDescriptor) michael@0: { } michael@0: #endif michael@0: michael@0: NS_DECL_THREADSAFE_ISUPPORTS michael@0: NS_DECL_NSIRUNNABLE michael@0: michael@0: void Dispatch(); michael@0: michael@0: private: michael@0: ~CloseFileRunnable(); michael@0: michael@0: void CloseFile(); michael@0: }; michael@0: michael@0: } // namespace ipc michael@0: } // namespace mozilla michael@0: michael@0: #endif // mozilla_ipc_FileDescriptorUtils_h