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

Side by Side Diff: base/mach_ipc_mac.mm

Issue 3443002: [Mac] Replace the existing browser-child mach ipc with a long-lived listener ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 3 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/mach_ipc_mac.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) 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 #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"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 return; 191 return;
192 192
193 init_result_ = mach_port_insert_right(current_task, 193 init_result_ = mach_port_insert_right(current_task,
194 port_, 194 port_,
195 port_, 195 port_,
196 MACH_MSG_TYPE_MAKE_SEND); 196 MACH_MSG_TYPE_MAKE_SEND);
197 197
198 if (init_result_ != KERN_SUCCESS) 198 if (init_result_ != KERN_SUCCESS)
199 return; 199 return;
200 200
201 NSPort *ns_port = [NSMachPort portWithMachPort:port_]; 201 // Without |NSMachPortDeallocateNone|, the NSMachPort seems to deallocate
202 // receive rights on port when it is eventually released. It is not necessary
203 // to deallocate any rights here as |port_| is fully deallocated in the
204 // ReceivePort destructor.
205 NSPort *ns_port = [NSMachPort portWithMachPort:port_
206 options:NSMachPortDeallocateNone];
202 NSString *port_name = [NSString stringWithUTF8String:receive_port_name]; 207 NSString *port_name = [NSString stringWithUTF8String:receive_port_name];
203 [[NSMachBootstrapServer sharedInstance] registerPort:ns_port name:port_name]; 208 [[NSMachBootstrapServer sharedInstance] registerPort:ns_port name:port_name];
204 } 209 }
205 210
206 //============================================================================== 211 //==============================================================================
207 // create a new mach port for receiving messages 212 // create a new mach port for receiving messages
208 ReceivePort::ReceivePort() { 213 ReceivePort::ReceivePort() {
209 mach_port_t current_task = mach_task_self(); 214 mach_port_t current_task = mach_task_self();
210 215
211 init_result_ = mach_port_allocate(current_task, 216 init_result_ = mach_port_allocate(current_task,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 // return any error condition encountered in constructor 250 // return any error condition encountered in constructor
246 if (init_result_ != KERN_SUCCESS) 251 if (init_result_ != KERN_SUCCESS)
247 return init_result_; 252 return init_result_;
248 253
249 out_message->Head()->msgh_bits = 0; 254 out_message->Head()->msgh_bits = 0;
250 out_message->Head()->msgh_local_port = port_; 255 out_message->Head()->msgh_local_port = port_;
251 out_message->Head()->msgh_remote_port = MACH_PORT_NULL; 256 out_message->Head()->msgh_remote_port = MACH_PORT_NULL;
252 out_message->Head()->msgh_reserved = 0; 257 out_message->Head()->msgh_reserved = 0;
253 out_message->Head()->msgh_id = 0; 258 out_message->Head()->msgh_id = 0;
254 259
260 mach_msg_option_t rcv_options = MACH_RCV_MSG;
261 if (timeout != MACH_MSG_TIMEOUT_NONE)
262 rcv_options |= MACH_RCV_TIMEOUT;
263
255 kern_return_t result = mach_msg(out_message->Head(), 264 kern_return_t result = mach_msg(out_message->Head(),
256 MACH_RCV_MSG | MACH_RCV_TIMEOUT, 265 rcv_options,
257 0, 266 0,
258 out_message->MaxSize(), 267 out_message->MaxSize(),
259 port_, 268 port_,
260 timeout, // timeout in ms 269 timeout, // timeout in ms
261 MACH_PORT_NULL); 270 MACH_PORT_NULL);
262 271
263 return result; 272 return result;
264 } 273 }
265 274
266 #pragma mark - 275 #pragma mark -
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 message.Head()->msgh_size, 312 message.Head()->msgh_size,
304 0, 313 0,
305 MACH_PORT_NULL, 314 MACH_PORT_NULL,
306 timeout, // timeout in ms 315 timeout, // timeout in ms
307 MACH_PORT_NULL); 316 MACH_PORT_NULL);
308 317
309 return result; 318 return result;
310 } 319 }
311 320
312 } // namespace base 321 } // namespace base
OLDNEW
« no previous file with comments | « base/mach_ipc_mac.h ('k') | base/process_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698