|
1 |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #ifndef mozilla_ipc_FileDescriptorUtils_h |
|
7 #define mozilla_ipc_FileDescriptorUtils_h |
|
8 |
|
9 #include "mozilla/Attributes.h" |
|
10 #include "mozilla/ipc/FileDescriptor.h" |
|
11 #include "nsIRunnable.h" |
|
12 |
|
13 namespace mozilla { |
|
14 namespace ipc { |
|
15 |
|
16 // When Dispatch() is called (from main thread) this class arranges to close the |
|
17 // provided FileDescriptor on one of the socket transport service threads (to |
|
18 // avoid main thread I/O). |
|
19 class CloseFileRunnable MOZ_FINAL : public nsIRunnable |
|
20 { |
|
21 typedef mozilla::ipc::FileDescriptor FileDescriptor; |
|
22 |
|
23 FileDescriptor mFileDescriptor; |
|
24 |
|
25 public: |
|
26 CloseFileRunnable(const FileDescriptor& aFileDescriptor) |
|
27 #ifdef DEBUG |
|
28 ; |
|
29 #else |
|
30 : mFileDescriptor(aFileDescriptor) |
|
31 { } |
|
32 #endif |
|
33 |
|
34 NS_DECL_THREADSAFE_ISUPPORTS |
|
35 NS_DECL_NSIRUNNABLE |
|
36 |
|
37 void Dispatch(); |
|
38 |
|
39 private: |
|
40 ~CloseFileRunnable(); |
|
41 |
|
42 void CloseFile(); |
|
43 }; |
|
44 |
|
45 } // namespace ipc |
|
46 } // namespace mozilla |
|
47 |
|
48 #endif // mozilla_ipc_FileDescriptorUtils_h |