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

Side by Side Diff: chrome/common/mach_ipc_mac.h

Issue 437048: Mac: Proof of concept of IPCing renderer mach_port_ts. (Closed)
Patch Set: add memory stats Created 11 years 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
« no previous file with comments | « chrome/chrome.gyp ('k') | chrome/renderer/renderer_main.cc » ('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) 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
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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 // port and deallocate it in our destructor. 278 // port and deallocate it in our destructor.
278 ReceivePort(mach_port_t receive_port); 279 ReceivePort(mach_port_t receive_port);
279 280
280 // Create a new mach port for receiving messages 281 // Create a new mach port for receiving messages
281 ReceivePort(); 282 ReceivePort();
282 283
283 ~ReceivePort(); 284 ~ReceivePort();
284 285
285 // Waits on the mach port until message received or timeout 286 // Waits on the mach port until message received or timeout
286 kern_return_t WaitForMessage(MachReceiveMessage *out_message, 287 kern_return_t WaitForMessage(MachReceiveMessage *out_message,
287 mach_msg_timeout_t timeout); 288 mach_msg_timeout_t timeout); // in milliseconds
288 289
289 // The underlying mach port that we wrap 290 // The underlying mach port that we wrap
290 mach_port_t GetPort() const { return port_; } 291 mach_port_t GetPort() const { return port_; }
291 292
292 private: 293 private:
293 mach_port_t port_; 294 mach_port_t port_;
294 kern_return_t init_result_; 295 kern_return_t init_result_;
295 296
296 DISALLOW_COPY_AND_ASSIGN(ReceivePort); 297 DISALLOW_COPY_AND_ASSIGN(ReceivePort);
297 }; 298 };
(...skipping 13 matching lines...) Expand all
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_
OLDNEW
« no previous file with comments | « chrome/chrome.gyp ('k') | chrome/renderer/renderer_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698