OLD | NEW |
1 // Copyright (c) 2006-2008 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 #include "base/mach_ipc_mac.h" | 5 #include "base/mach_ipc_mac.h" |
6 | 6 |
7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
8 | 8 |
9 #include <stdio.h> | 9 #include <stdio.h> |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 | 11 |
12 namespace base { | 12 namespace base { |
13 | 13 |
| 14 // static |
| 15 const size_t MachSendMessage::kEmptyMessageSize = sizeof(mach_msg_header_t) + |
| 16 sizeof(mach_msg_body_t) + sizeof(MessageDataPacket); |
| 17 |
14 //============================================================================== | 18 //============================================================================== |
15 MachSendMessage::MachSendMessage(int32_t message_id) : MachMessage() { | 19 MachSendMessage::MachSendMessage(int32_t message_id) : MachMessage() { |
16 Initialize(message_id); | 20 Initialize(message_id); |
17 } | 21 } |
18 | 22 |
19 MachSendMessage::MachSendMessage(void *storage, size_t storage_length, | 23 MachSendMessage::MachSendMessage(void *storage, size_t storage_length, |
20 int32_t message_id) | 24 int32_t message_id) |
21 : MachMessage(storage, storage_length) { | 25 : MachMessage(storage, storage_length) { |
22 Initialize(message_id); | 26 Initialize(message_id); |
23 } | 27 } |
(...skipping 19 matching lines...) Expand all Loading... |
43 own_storage_(true) { | 47 own_storage_(true) { |
44 memset(storage_, 0, storage_length_bytes_); | 48 memset(storage_, 0, storage_length_bytes_); |
45 } | 49 } |
46 | 50 |
47 //============================================================================== | 51 //============================================================================== |
48 MachMessage::MachMessage(void *storage, size_t storage_length) | 52 MachMessage::MachMessage(void *storage, size_t storage_length) |
49 : storage_(static_cast<MachMessageData*>(storage)), | 53 : storage_(static_cast<MachMessageData*>(storage)), |
50 storage_length_bytes_(storage_length), | 54 storage_length_bytes_(storage_length), |
51 own_storage_(false) { | 55 own_storage_(false) { |
52 DCHECK(storage); | 56 DCHECK(storage); |
53 DCHECK(storage_length >= kEmptyMessageSize); | 57 DCHECK_GE(storage_length, kEmptyMessageSize); |
54 } | 58 } |
55 | 59 |
56 //============================================================================== | 60 //============================================================================== |
57 MachMessage::~MachMessage() { | 61 MachMessage::~MachMessage() { |
58 if (own_storage_) { | 62 if (own_storage_) { |
59 delete storage_; | 63 delete storage_; |
60 storage_ = NULL; | 64 storage_ = NULL; |
61 } | 65 } |
62 } | 66 } |
63 | 67 |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 message.Head()->msgh_size, | 316 message.Head()->msgh_size, |
313 0, | 317 0, |
314 MACH_PORT_NULL, | 318 MACH_PORT_NULL, |
315 timeout, // timeout in ms | 319 timeout, // timeout in ms |
316 MACH_PORT_NULL); | 320 MACH_PORT_NULL); |
317 | 321 |
318 return result; | 322 return result; |
319 } | 323 } |
320 | 324 |
321 } // namespace base | 325 } // namespace base |
OLD | NEW |