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

Side by Side Diff: sandbox/mac/mach_message_server.cc

Issue 1136953012: Move DispatchSourceMach from //sandbox/mac to //base/mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « sandbox/mac/mach_message_server.h ('k') | sandbox/mac/sandbox_mac.gypi » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "sandbox/mac/mach_message_server.h" 5 #include "sandbox/mac/mach_message_server.h"
6 6
7 #include <bsm/libbsm.h> 7 #include <bsm/libbsm.h>
8 #include <servers/bootstrap.h> 8 #include <servers/bootstrap.h>
9 9
10 #include <string> 10 #include <string>
11 11
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/mac/mach_logging.h" 13 #include "base/mac/mach_logging.h"
14 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
15 #include "sandbox/mac/dispatch_source_mach.h"
16 15
17 namespace sandbox { 16 namespace sandbox {
18 17
19 MachMessageServer::MachMessageServer( 18 MachMessageServer::MachMessageServer(
20 MessageDemuxer* demuxer, 19 MessageDemuxer* demuxer,
21 mach_port_t server_receive_right, 20 mach_port_t server_receive_right,
22 mach_msg_size_t buffer_size) 21 mach_msg_size_t buffer_size)
23 : demuxer_(demuxer), 22 : demuxer_(demuxer),
24 server_port_(server_receive_right), 23 server_port_(server_receive_right),
25 buffer_size_( 24 buffer_size_(
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 kr = vm_allocate(task, &buffer, buffer_size_, kMachMsgMemoryFlags); 61 kr = vm_allocate(task, &buffer, buffer_size_, kMachMsgMemoryFlags);
63 if (kr != KERN_SUCCESS) { 62 if (kr != KERN_SUCCESS) {
64 MACH_LOG(ERROR, kr) << "Failed to allocate reply buffer."; 63 MACH_LOG(ERROR, kr) << "Failed to allocate reply buffer.";
65 return false; 64 return false;
66 } 65 }
67 reply_buffer_.reset(buffer, buffer_size_); 66 reply_buffer_.reset(buffer, buffer_size_);
68 67
69 // Set up the dispatch queue to service the bootstrap port. 68 // Set up the dispatch queue to service the bootstrap port.
70 std::string label = base::StringPrintf( 69 std::string label = base::StringPrintf(
71 "org.chromium.sandbox.MachMessageServer.%p", demuxer_); 70 "org.chromium.sandbox.MachMessageServer.%p", demuxer_);
72 dispatch_source_.reset(new DispatchSourceMach( 71 dispatch_source_.reset(new base::DispatchSourceMach(
73 label.c_str(), server_port_.get(), ^{ ReceiveMessage(); })); 72 label.c_str(), server_port_.get(), ^{ ReceiveMessage(); }));
74 dispatch_source_->Resume(); 73 dispatch_source_->Resume();
75 74
76 return true; 75 return true;
77 } 76 }
78 77
79 pid_t MachMessageServer::GetMessageSenderPID(IPCMessage request) { 78 pid_t MachMessageServer::GetMessageSenderPID(IPCMessage request) {
80 // Get the PID of the task that sent this request. This requires getting at 79 // Get the PID of the task that sent this request. This requires getting at
81 // the trailer of the message, from the header. 80 // the trailer of the message, from the header.
82 mach_msg_audit_trailer_t* trailer = 81 mach_msg_audit_trailer_t* trailer =
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 // forwarded message was sent from the process hosting this sandbox server, 183 // forwarded message was sent from the process hosting this sandbox server,
185 // destroying the message could also destroy rights held outside the scope of 184 // destroying the message could also destroy rights held outside the scope of
186 // this message server. 185 // this message server.
187 if (!did_forward_message_) { 186 if (!did_forward_message_) {
188 mach_msg_destroy(request); 187 mach_msg_destroy(request);
189 mach_msg_destroy(reply); 188 mach_msg_destroy(reply);
190 } 189 }
191 } 190 }
192 191
193 } // namespace sandbox 192 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/mac/mach_message_server.h ('k') | sandbox/mac/sandbox_mac.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698