1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/ipc/glue/FileDescriptorUtils.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,48 @@ 1.4 + 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef mozilla_ipc_FileDescriptorUtils_h 1.10 +#define mozilla_ipc_FileDescriptorUtils_h 1.11 + 1.12 +#include "mozilla/Attributes.h" 1.13 +#include "mozilla/ipc/FileDescriptor.h" 1.14 +#include "nsIRunnable.h" 1.15 + 1.16 +namespace mozilla { 1.17 +namespace ipc { 1.18 + 1.19 +// When Dispatch() is called (from main thread) this class arranges to close the 1.20 +// provided FileDescriptor on one of the socket transport service threads (to 1.21 +// avoid main thread I/O). 1.22 +class CloseFileRunnable MOZ_FINAL : public nsIRunnable 1.23 +{ 1.24 + typedef mozilla::ipc::FileDescriptor FileDescriptor; 1.25 + 1.26 + FileDescriptor mFileDescriptor; 1.27 + 1.28 +public: 1.29 + CloseFileRunnable(const FileDescriptor& aFileDescriptor) 1.30 +#ifdef DEBUG 1.31 + ; 1.32 +#else 1.33 + : mFileDescriptor(aFileDescriptor) 1.34 + { } 1.35 +#endif 1.36 + 1.37 + NS_DECL_THREADSAFE_ISUPPORTS 1.38 + NS_DECL_NSIRUNNABLE 1.39 + 1.40 + void Dispatch(); 1.41 + 1.42 +private: 1.43 + ~CloseFileRunnable(); 1.44 + 1.45 + void CloseFile(); 1.46 +}; 1.47 + 1.48 +} // namespace ipc 1.49 +} // namespace mozilla 1.50 + 1.51 +#endif // mozilla_ipc_FileDescriptorUtils_h