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

Side by Side Diff: base/mach_ipc_mac.h

Issue 7474010: mac: Components build for base, easy part (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 4 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 | « base/mac/scoped_nsexception_enabler.h ('k') | base/process_util.h » ('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 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>
12 #include <sys/types.h> 12 #include <sys/types.h>
13 13
14 #include <CoreServices/CoreServices.h> 14 #include <CoreServices/CoreServices.h>
15 15
16 #include "base/base_api.h"
16 #include "base/basictypes.h" 17 #include "base/basictypes.h"
17 18
18 //============================================================================== 19 //==============================================================================
19 // DISCUSSION: 20 // DISCUSSION:
20 // 21 //
21 // The three main classes of interest are 22 // The three main classes of interest are
22 // 23 //
23 // MachMessage: a wrapper for a Mach message of the following form 24 // MachMessage: a wrapper for a Mach message of the following form
24 // mach_msg_header_t 25 // mach_msg_header_t
25 // mach_msg_body_t 26 // mach_msg_body_t
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 // or it can manage storage internally. 132 // or it can manage storage internally.
132 // 1. If storage is allocated internally, the combined size of the descriptors 133 // 1. If storage is allocated internally, the combined size of the descriptors
133 // plus data must be less than 1024. But as a benefit no memory allocation is 134 // plus data must be less than 1024. But as a benefit no memory allocation is
134 // necessary. 135 // necessary.
135 // 2. For external storage, a buffer of at least EmptyMessageSize() must be 136 // 2. For external storage, a buffer of at least EmptyMessageSize() must be
136 // provided. 137 // provided.
137 // 138 //
138 // A MachMessage object is used by ReceivePort::WaitForMessage 139 // A MachMessage object is used by ReceivePort::WaitForMessage
139 // and MachPortSender::SendMessage 140 // and MachPortSender::SendMessage
140 // 141 //
141 class MachMessage { 142 class BASE_API MachMessage {
142 public: 143 public:
143 static const size_t kEmptyMessageSize; 144 static const size_t kEmptyMessageSize;
144 145
145 virtual ~MachMessage(); 146 virtual ~MachMessage();
146 147
147 // The receiver of the message can retrieve the raw data this way 148 // The receiver of the message can retrieve the raw data this way
148 u_int8_t *GetData() { 149 u_int8_t *GetData() {
149 return GetDataLength() > 0 ? GetDataPacket()->data : NULL; 150 return GetDataLength() > 0 ? GetDataPacket()->data : NULL;
150 } 151 }
151 152
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 public: 238 public:
238 MachReceiveMessage() : MachMessage() {} 239 MachReceiveMessage() : MachMessage() {}
239 MachReceiveMessage(void *storage, size_t storage_length) 240 MachReceiveMessage(void *storage, size_t storage_length)
240 : MachMessage(storage, storage_length) {} 241 : MachMessage(storage, storage_length) {}
241 242
242 private: 243 private:
243 DISALLOW_COPY_AND_ASSIGN(MachReceiveMessage); 244 DISALLOW_COPY_AND_ASSIGN(MachReceiveMessage);
244 }; 245 };
245 246
246 //============================================================================== 247 //==============================================================================
247 class MachSendMessage : public MachMessage { 248 class BASE_API MachSendMessage : public MachMessage {
248 public: 249 public:
249 explicit MachSendMessage(int32_t message_id); 250 explicit MachSendMessage(int32_t message_id);
250 MachSendMessage(void *storage, size_t storage_length, int32_t message_id); 251 MachSendMessage(void *storage, size_t storage_length, int32_t message_id);
251 252
252 private: 253 private:
253 void Initialize(int32_t message_id); 254 void Initialize(int32_t message_id);
254 255
255 DISALLOW_COPY_AND_ASSIGN(MachSendMessage); 256 DISALLOW_COPY_AND_ASSIGN(MachSendMessage);
256 }; 257 };
257 258
258 //============================================================================== 259 //==============================================================================
259 // Represents a Mach port for which we have receive rights 260 // Represents a Mach port for which we have receive rights
260 class ReceivePort { 261 class BASE_API ReceivePort {
261 public: 262 public:
262 // Creates a new Mach port for receiving messages and registers a name for it 263 // Creates a new Mach port for receiving messages and registers a name for it
263 explicit ReceivePort(const char *receive_port_name); 264 explicit ReceivePort(const char *receive_port_name);
264 265
265 // Given an already existing Mach port, use it. We take ownership of the 266 // Given an already existing Mach port, use it. We take ownership of the
266 // port and deallocate it in our destructor. 267 // port and deallocate it in our destructor.
267 explicit ReceivePort(mach_port_t receive_port); 268 explicit ReceivePort(mach_port_t receive_port);
268 269
269 // Create a new Mach port for receiving messages 270 // Create a new Mach port for receiving messages
270 ReceivePort(); 271 ReceivePort();
(...skipping 10 matching lines...) Expand all
281 282
282 private: 283 private:
283 mach_port_t port_; 284 mach_port_t port_;
284 kern_return_t init_result_; 285 kern_return_t init_result_;
285 286
286 DISALLOW_COPY_AND_ASSIGN(ReceivePort); 287 DISALLOW_COPY_AND_ASSIGN(ReceivePort);
287 }; 288 };
288 289
289 //============================================================================== 290 //==============================================================================
290 // Represents a Mach port for which we have send rights 291 // Represents a Mach port for which we have send rights
291 class MachPortSender { 292 class BASE_API MachPortSender {
292 public: 293 public:
293 // get a port with send rights corresponding to a named registered service 294 // get a port with send rights corresponding to a named registered service
294 explicit MachPortSender(const char *receive_port_name); 295 explicit MachPortSender(const char *receive_port_name);
295 296
296 297
297 // Given an already existing Mach port, use it. Does not take ownership of 298 // Given an already existing Mach port, use it. Does not take ownership of
298 // |send_port|. 299 // |send_port|.
299 explicit MachPortSender(mach_port_t send_port); 300 explicit MachPortSender(mach_port_t send_port);
300 301
301 kern_return_t SendMessage(MachSendMessage &message, 302 kern_return_t SendMessage(MachSendMessage &message,
302 mach_msg_timeout_t timeout); 303 mach_msg_timeout_t timeout);
303 304
304 private: 305 private:
305 mach_port_t send_port_; 306 mach_port_t send_port_;
306 kern_return_t init_result_; 307 kern_return_t init_result_;
307 308
308 DISALLOW_COPY_AND_ASSIGN(MachPortSender); 309 DISALLOW_COPY_AND_ASSIGN(MachPortSender);
309 }; 310 };
310 311
311 } // namespace base 312 } // namespace base
312 313
313 #endif // BASE_MACH_IPC_MAC_H_ 314 #endif // BASE_MACH_IPC_MAC_H_
OLDNEW
« no previous file with comments | « base/mac/scoped_nsexception_enabler.h ('k') | base/process_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698