OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef IPC_FILE_DESCRIPTOR_SET_POSIX_H_ | 5 #ifndef IPC_FILE_DESCRIPTOR_SET_POSIX_H_ |
6 #define IPC_FILE_DESCRIPTOR_SET_POSIX_H_ | 6 #define IPC_FILE_DESCRIPTOR_SET_POSIX_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 FileDescriptorSet(); | 23 FileDescriptorSet(); |
24 | 24 |
25 // This is the maximum number of descriptors per message. We need to know this | 25 // This is the maximum number of descriptors per message. We need to know this |
26 // because the control message kernel interface has to be given a buffer which | 26 // because the control message kernel interface has to be given a buffer which |
27 // is large enough to store all the descriptor numbers. Otherwise the kernel | 27 // is large enough to store all the descriptor numbers. Otherwise the kernel |
28 // tells us that it truncated the control data and the extra descriptors are | 28 // tells us that it truncated the control data and the extra descriptors are |
29 // lost. | 29 // lost. |
30 // | 30 // |
31 // In debugging mode, it's a fatal error to try and add more than this number | 31 // In debugging mode, it's a fatal error to try and add more than this number |
32 // of descriptors to a FileDescriptorSet. | 32 // of descriptors to a FileDescriptorSet. |
33 static const size_t kMaxDescriptorsPerMessage = 5; | 33 static const size_t kMaxDescriptorsPerMessage = 7; |
34 | 34 |
35 // --------------------------------------------------------------------------- | 35 // --------------------------------------------------------------------------- |
36 // Interfaces for building during message serialisation... | 36 // Interfaces for building during message serialisation... |
37 | 37 |
38 // Add a descriptor to the end of the set. Returns false iff the set is full. | 38 // Add a descriptor to the end of the set. Returns false iff the set is full. |
39 bool Add(int fd); | 39 bool Add(int fd); |
40 // Add a descriptor to the end of the set and automatically close it after | 40 // Add a descriptor to the end of the set and automatically close it after |
41 // transmission. Returns false iff the set is full. | 41 // transmission. Returns false iff the set is full. |
42 bool AddAndAutoClose(int fd); | 42 bool AddAndAutoClose(int fd); |
43 | 43 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 // This contains the index of the next descriptor which should be consumed. | 105 // This contains the index of the next descriptor which should be consumed. |
106 // It's used in a couple of ways. Firstly, at destruction we can check that | 106 // It's used in a couple of ways. Firstly, at destruction we can check that |
107 // all the descriptors have been read (with GetNthDescriptor). Secondly, we | 107 // all the descriptors have been read (with GetNthDescriptor). Secondly, we |
108 // can check that they are read in order. | 108 // can check that they are read in order. |
109 mutable unsigned consumed_descriptor_highwater_; | 109 mutable unsigned consumed_descriptor_highwater_; |
110 | 110 |
111 DISALLOW_COPY_AND_ASSIGN(FileDescriptorSet); | 111 DISALLOW_COPY_AND_ASSIGN(FileDescriptorSet); |
112 }; | 112 }; |
113 | 113 |
114 #endif // IPC_FILE_DESCRIPTOR_SET_POSIX_H_ | 114 #endif // IPC_FILE_DESCRIPTOR_SET_POSIX_H_ |
OLD | NEW |