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

Side by Side Diff: base/mach_ipc_mac.h

Issue 6688056: Updating DCHECK() to DCHECK_GE() in base/ dir (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Updating license header Created 9 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | base/mach_ipc_mac.mm » ('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) 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 #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>
11 #include <servers/bootstrap.h> 11 #include <servers/bootstrap.h>
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 // plus data must be less than 1024. But as a benefit no memory allocation is 133 // plus data must be less than 1024. But as a benefit no memory allocation is
134 // necessary. 134 // necessary.
135 // 2. For external storage, a buffer of at least EmptyMessageSize() must be 135 // 2. For external storage, a buffer of at least EmptyMessageSize() must be
136 // provided. 136 // provided.
137 // 137 //
138 // A MachMessage object is used by ReceivePort::WaitForMessage 138 // A MachMessage object is used by ReceivePort::WaitForMessage
139 // and MachPortSender::SendMessage 139 // and MachPortSender::SendMessage
140 // 140 //
141 class MachMessage { 141 class MachMessage {
142 public: 142 public:
143 static const size_t kEmptyMessageSize;
143 144
144 virtual ~MachMessage(); 145 virtual ~MachMessage();
145 146
146 // The receiver of the message can retrieve the raw data this way 147 // The receiver of the message can retrieve the raw data this way
147 u_int8_t *GetData() { 148 u_int8_t *GetData() {
148 return GetDataLength() > 0 ? GetDataPacket()->data : NULL; 149 return GetDataLength() > 0 ? GetDataPacket()->data : NULL;
149 } 150 }
150 151
151 u_int32_t GetDataLength() { 152 u_int32_t GetDataLength() {
152 return EndianU32_LtoN(GetDataPacket()->data_length); 153 return EndianU32_LtoN(GetDataPacket()->data_length);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 void SetDescriptorCount(int n); 203 void SetDescriptorCount(int n);
203 void SetDescriptor(int n, const MachMsgPortDescriptor &desc); 204 void SetDescriptor(int n, const MachMsgPortDescriptor &desc);
204 205
205 // Returns total message size setting msgh_size in the header to this value 206 // Returns total message size setting msgh_size in the header to this value
206 int CalculateSize(); 207 int CalculateSize();
207 208
208 // Returns total storage size that this object can grow to, this is inclusive 209 // Returns total storage size that this object can grow to, this is inclusive
209 // of the Mach header. 210 // of the Mach header.
210 size_t MaxSize() const { return storage_length_bytes_; } 211 size_t MaxSize() const { return storage_length_bytes_; }
211 212
212 protected:
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:
226 // The size of an empty message with no data.
227 static const size_t kEmptyMessageSize = sizeof(mach_msg_header_t) +
228 sizeof(mach_msg_body_t) +
229 sizeof(MessageDataPacket);
230
231 private:
232 MachMessageData *storage_; 223 MachMessageData *storage_;
233 size_t storage_length_bytes_; 224 size_t storage_length_bytes_;
234 bool own_storage_; // Is storage owned by this object? 225 bool own_storage_; // Is storage owned by this object?
235 }; 226 };
236 227
237 //============================================================================== 228 //==============================================================================
238 // MachReceiveMessage and MachSendMessage are useful to separate the idea 229 // MachReceiveMessage and MachSendMessage are useful to separate the idea
239 // of a Mach message being sent and being received, and adds increased type 230 // of a Mach message being sent and being received, and adds increased type
240 // safety: 231 // safety:
241 // ReceivePort::WaitForMessage() only accepts a MachReceiveMessage 232 // ReceivePort::WaitForMessage() only accepts a MachReceiveMessage
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 private: 304 private:
314 mach_port_t send_port_; 305 mach_port_t send_port_;
315 kern_return_t init_result_; 306 kern_return_t init_result_;
316 307
317 DISALLOW_COPY_AND_ASSIGN(MachPortSender); 308 DISALLOW_COPY_AND_ASSIGN(MachPortSender);
318 }; 309 };
319 310
320 } // namespace base 311 } // namespace base
321 312
322 #endif // BASE_MACH_IPC_MAC_H_ 313 #endif // BASE_MACH_IPC_MAC_H_
OLDNEW
« no previous file with comments | « no previous file | base/mach_ipc_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698