Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Side by Side Diff: ipc/ipc_message_attachment_set.h

Issue 866223005: IPC: Add MojoHandleAttachment (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing windows build again... Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ipc/ipc_message_attachment.h ('k') | ipc/ipc_message_attachment_set.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_IPC_MESSAGE_ATTACHMENT_SET_H_ 5 #ifndef IPC_IPC_MESSAGE_ATTACHMENT_SET_H_
6 #define IPC_IPC_MESSAGE_ATTACHMENT_SET_H_ 6 #define IPC_IPC_MESSAGE_ATTACHMENT_SET_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 17 matching lines...) Expand all
28 // ----------------------------------------------------------------------------- 28 // -----------------------------------------------------------------------------
29 class IPC_EXPORT MessageAttachmentSet 29 class IPC_EXPORT MessageAttachmentSet
30 : public base::RefCountedThreadSafe<MessageAttachmentSet> { 30 : public base::RefCountedThreadSafe<MessageAttachmentSet> {
31 public: 31 public:
32 MessageAttachmentSet(); 32 MessageAttachmentSet();
33 33
34 // Return the number of attachments 34 // Return the number of attachments
35 unsigned size() const; 35 unsigned size() const;
36 // Return the number of file descriptors 36 // Return the number of file descriptors
37 unsigned num_descriptors() const; 37 unsigned num_descriptors() const;
38 // Return the number of mojo handles in the attachment set
39 unsigned num_mojo_handles() const;
40
38 // Return true if no unconsumed descriptors remain 41 // Return true if no unconsumed descriptors remain
39 bool empty() const { return 0 == size(); } 42 bool empty() const { return 0 == size(); }
40 43
41 bool AddAttachment(scoped_refptr<MessageAttachment> attachment); 44 bool AddAttachment(scoped_refptr<MessageAttachment> attachment);
42 45
43 // Take the nth attachment from the beginning of the set, Code using this 46 // Take the nth attachment from the beginning of the set, Code using this
44 // /must/ access the attachments in order, and must do it at most once. 47 // /must/ access the attachments in order, and must do it at most once.
45 // 48 //
46 // This interface is designed for the deserialising code as it doesn't 49 // This interface is designed for the deserialising code as it doesn't
47 // support close flags. 50 // support close flags.
48 // returns: an attachment, or nullptr on error 51 // returns: an attachment, or nullptr on error
49 scoped_refptr<MessageAttachment> GetAttachmentAt(unsigned index); 52 scoped_refptr<MessageAttachment> GetAttachmentAt(unsigned index);
50 53
54 // This must be called after transmitting the descriptors returned by
55 // PeekDescriptors. It marks all the descriptors as consumed and closes those
56 // which are auto-close.
57 void CommitAll();
58
51 #if defined(OS_POSIX) 59 #if defined(OS_POSIX)
52 // This is the maximum number of descriptors per message. We need to know this 60 // This is the maximum number of descriptors per message. We need to know this
53 // because the control message kernel interface has to be given a buffer which 61 // because the control message kernel interface has to be given a buffer which
54 // is large enough to store all the descriptor numbers. Otherwise the kernel 62 // is large enough to store all the descriptor numbers. Otherwise the kernel
55 // tells us that it truncated the control data and the extra descriptors are 63 // tells us that it truncated the control data and the extra descriptors are
56 // lost. 64 // lost.
57 // 65 //
58 // In debugging mode, it's a fatal error to try and add more than this number 66 // In debugging mode, it's a fatal error to try and add more than this number
59 // of descriptors to a MessageAttachmentSet. 67 // of descriptors to a MessageAttachmentSet.
60 static const size_t kMaxDescriptorsPerMessage = 7; 68 static const size_t kMaxDescriptorsPerMessage = 7;
61 69
62 // --------------------------------------------------------------------------- 70 // ---------------------------------------------------------------------------
63 // Interfaces for transmission... 71 // Interfaces for transmission...
64 72
65 // Fill an array with file descriptors without 'consuming' them. CommitAll 73 // Fill an array with file descriptors without 'consuming' them. CommitAll
66 // must be called after these descriptors have been transmitted. 74 // must be called after these descriptors have been transmitted.
67 // buffer: (output) a buffer of, at least, size() integers. 75 // buffer: (output) a buffer of, at least, size() integers.
68 void PeekDescriptors(base::PlatformFile* buffer) const; 76 void PeekDescriptors(base::PlatformFile* buffer) const;
69 // This must be called after transmitting the descriptors returned by
70 // PeekDescriptors. It marks all the descriptors as consumed and closes those
71 // which are auto-close.
72 void CommitAll();
73 // Returns true if any contained file descriptors appear to be handles to a 77 // Returns true if any contained file descriptors appear to be handles to a
74 // directory. 78 // directory.
75 bool ContainsDirectoryDescriptor() const; 79 bool ContainsDirectoryDescriptor() const;
76 // Fetch all filedescriptors with the "auto close" property. 80 // Fetch all filedescriptors with the "auto close" property.
77 // Used instead of CommitAll() when closing must be handled manually. 81 // Used instead of CommitAll() when closing must be handled manually.
78 void ReleaseFDsToClose(std::vector<base::PlatformFile>* fds); 82 void ReleaseFDsToClose(std::vector<base::PlatformFile>* fds);
79 83
80 // --------------------------------------------------------------------------- 84 // ---------------------------------------------------------------------------
81 85
82 // --------------------------------------------------------------------------- 86 // ---------------------------------------------------------------------------
(...skipping 22 matching lines...) Expand all
105 // all the descriptors have been read (with GetNthDescriptor). Secondly, we 109 // all the descriptors have been read (with GetNthDescriptor). Secondly, we
106 // can check that they are read in order. 110 // can check that they are read in order.
107 mutable unsigned consumed_descriptor_highwater_; 111 mutable unsigned consumed_descriptor_highwater_;
108 112
109 DISALLOW_COPY_AND_ASSIGN(MessageAttachmentSet); 113 DISALLOW_COPY_AND_ASSIGN(MessageAttachmentSet);
110 }; 114 };
111 115
112 } // namespace IPC 116 } // namespace IPC
113 117
114 #endif // IPC_IPC_MESSAGE_ATTACHMENT_SET_H_ 118 #endif // IPC_IPC_MESSAGE_ATTACHMENT_SET_H_
OLDNEW
« no previous file with comments | « ipc/ipc_message_attachment.h ('k') | ipc/ipc_message_attachment_set.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698