OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 BASE_MACH_IPC_MAC_H_ | 5 #ifndef BASE_MACH_IPC_MAC_H_ |
6 #define BASE_MACH_IPC_MAC_H_ | 6 #define BASE_MACH_IPC_MAC_H_ |
7 | 7 |
8 #include <mach/mach.h> | 8 #include <mach/mach.h> |
9 #include <mach/message.h> | 9 #include <mach/message.h> |
10 #include <servers/bootstrap.h> | 10 #include <servers/bootstrap.h> |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 GetDataPacket()->id = EndianU32_NtoL(message_id); | 160 GetDataPacket()->id = EndianU32_NtoL(message_id); |
161 } | 161 } |
162 | 162 |
163 int32_t GetMessageID() { return EndianU32_LtoN(GetDataPacket()->id); } | 163 int32_t GetMessageID() { return EndianU32_LtoN(GetDataPacket()->id); } |
164 | 164 |
165 // Adds a descriptor (typically a mach port) to be translated | 165 // Adds a descriptor (typically a mach port) to be translated |
166 // returns true if successful, otherwise not enough space | 166 // returns true if successful, otherwise not enough space |
167 bool AddDescriptor(const MachMsgPortDescriptor &desc); | 167 bool AddDescriptor(const MachMsgPortDescriptor &desc); |
168 | 168 |
169 int GetDescriptorCount() const { | 169 int GetDescriptorCount() const { |
170 return storage_->body.msgh_descriptor_count; | 170 return storage_->body.msgh_descriptor_count; |
171 } | 171 } |
| 172 |
172 MachMsgPortDescriptor *GetDescriptor(int n); | 173 MachMsgPortDescriptor *GetDescriptor(int n); |
173 | 174 |
174 // Convenience method which gets the mach port described by the descriptor | 175 // Convenience method which gets the mach port described by the descriptor |
175 mach_port_t GetTranslatedPort(int n); | 176 mach_port_t GetTranslatedPort(int n); |
176 | 177 |
177 // A simple message is one with no descriptors | 178 // A simple message is one with no descriptors |
178 bool IsSimpleMessage() const { return GetDescriptorCount() == 0; } | 179 bool IsSimpleMessage() const { return GetDescriptorCount() == 0; } |
179 | 180 |
180 // Sets raw data for the message (returns false if not enough space) | 181 // Sets raw data for the message (returns false if not enough space) |
181 bool SetData(const void* data, int32_t data_length); | 182 bool SetData(const void* data, int32_t data_length); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 mach_msg_timeout_t timeout); | 312 mach_msg_timeout_t timeout); |
312 | 313 |
313 private: | 314 private: |
314 mach_port_t send_port_; | 315 mach_port_t send_port_; |
315 kern_return_t init_result_; | 316 kern_return_t init_result_; |
316 | 317 |
317 DISALLOW_COPY_AND_ASSIGN(MachPortSender); | 318 DISALLOW_COPY_AND_ASSIGN(MachPortSender); |
318 }; | 319 }; |
319 | 320 |
320 #endif // BASE_MACH_IPC_MAC_H_ | 321 #endif // BASE_MACH_IPC_MAC_H_ |
OLD | NEW |