Chromium Code Reviews| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <mach/mach.h> | 9 #include <mach/mach.h> |
| 10 #include <mach/message.h> | 10 #include <mach/message.h> |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 202 void SetDescriptorCount(int n); | 202 void SetDescriptorCount(int n); |
| 203 void SetDescriptor(int n, const MachMsgPortDescriptor &desc); | 203 void SetDescriptor(int n, const MachMsgPortDescriptor &desc); |
| 204 | 204 |
| 205 // Returns total message size setting msgh_size in the header to this value | 205 // Returns total message size setting msgh_size in the header to this value |
| 206 int CalculateSize(); | 206 int CalculateSize(); |
| 207 | 207 |
| 208 // Returns total storage size that this object can grow to, this is inclusive | 208 // Returns total storage size that this object can grow to, this is inclusive |
| 209 // of the Mach header. | 209 // of the Mach header. |
| 210 size_t MaxSize() const { return storage_length_bytes_; } | 210 size_t MaxSize() const { return storage_length_bytes_; } |
| 211 | 211 |
| 212 protected: | 212 protected: |
|
Peter Kasting
2011/03/27 05:56:09
Nit: While here, kill this extra "protected"
KushalP
2011/03/27 10:17:17
Done.
| |
| 213 mach_msg_header_t *Head() { return &(storage_->head); } | 213 mach_msg_header_t *Head() { return &(storage_->head); } |
| 214 | 214 |
| 215 private: | 215 private: |
| 216 struct MachMessageData { | 216 struct MachMessageData { |
| 217 mach_msg_header_t head; | 217 mach_msg_header_t head; |
| 218 mach_msg_body_t body; | 218 mach_msg_body_t body; |
| 219 // descriptors and data may be embedded here. | 219 // descriptors and data may be embedded here. |
| 220 u_int8_t padding[1024]; | 220 u_int8_t padding[1024]; |
| 221 }; | 221 }; |
| 222 | 222 |
| 223 // kEmptyMessageSize needs to have the definition of MachMessageData before | |
| 224 // it. | |
| 225 public: | 223 public: |
| 226 // The size of an empty message with no data. | 224 static const size_t kEmptyMessageSize; |
| 227 static const size_t kEmptyMessageSize = sizeof(mach_msg_header_t) + | |
| 228 sizeof(mach_msg_body_t) + | |
| 229 sizeof(MessageDataPacket); | |
| 230 | 225 |
| 231 private: | 226 private: |
| 232 MachMessageData *storage_; | 227 MachMessageData *storage_; |
| 233 size_t storage_length_bytes_; | 228 size_t storage_length_bytes_; |
| 234 bool own_storage_; // Is storage owned by this object? | 229 bool own_storage_; // Is storage owned by this object? |
| 235 }; | 230 }; |
| 236 | 231 |
| 237 //============================================================================== | 232 //============================================================================== |
| 238 // MachReceiveMessage and MachSendMessage are useful to separate the idea | 233 // MachReceiveMessage and MachSendMessage are useful to separate the idea |
| 239 // of a Mach message being sent and being received, and adds increased type | 234 // of a Mach message being sent and being received, and adds increased type |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 313 private: | 308 private: |
| 314 mach_port_t send_port_; | 309 mach_port_t send_port_; |
| 315 kern_return_t init_result_; | 310 kern_return_t init_result_; |
| 316 | 311 |
| 317 DISALLOW_COPY_AND_ASSIGN(MachPortSender); | 312 DISALLOW_COPY_AND_ASSIGN(MachPortSender); |
| 318 }; | 313 }; |
| 319 | 314 |
| 320 } // namespace base | 315 } // namespace base |
| 321 | 316 |
| 322 #endif // BASE_MACH_IPC_MAC_H_ | 317 #endif // BASE_MACH_IPC_MAC_H_ |
| OLD | NEW |