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

Side by Side Diff: sandbox/mac/xpc_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/xpc_message_server.h ('k') | no next file » | 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/xpc_message_server.h" 5 #include "sandbox/mac/xpc_message_server.h"
6 6
7 #include <bsm/libbsm.h> 7 #include <bsm/libbsm.h>
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/mac/mach_logging.h" 11 #include "base/mac/mach_logging.h"
12 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "sandbox/mac/dispatch_source_mach.h"
14 #include "sandbox/mac/xpc.h" 13 #include "sandbox/mac/xpc.h"
15 14
16 #if defined(MAC_OS_X_VERSION_10_7) && \ 15 #if defined(MAC_OS_X_VERSION_10_7) && \
17 MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7 16 MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7
18 // Redeclare methods that only exist on 10.7+ to suppress 17 // Redeclare methods that only exist on 10.7+ to suppress
19 // -Wpartial-availability warnings. 18 // -Wpartial-availability warnings.
20 extern "C" { 19 extern "C" {
21 XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL_ALL 20 XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL_ALL
22 xpc_object_t 21 xpc_object_t
23 xpc_dictionary_create_reply(xpc_object_t original); 22 xpc_dictionary_create_reply(xpc_object_t original);
(...skipping 21 matching lines...) Expand all
45 if ((kr = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, 44 if ((kr = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE,
46 &port)) != KERN_SUCCESS) { 45 &port)) != KERN_SUCCESS) {
47 MACH_LOG(ERROR, kr) << "Failed to allocate new server port."; 46 MACH_LOG(ERROR, kr) << "Failed to allocate new server port.";
48 return false; 47 return false;
49 } 48 }
50 server_port_.reset(port); 49 server_port_.reset(port);
51 } 50 }
52 51
53 std::string label = base::StringPrintf( 52 std::string label = base::StringPrintf(
54 "org.chromium.sandbox.XPCMessageServer.%p", demuxer_); 53 "org.chromium.sandbox.XPCMessageServer.%p", demuxer_);
55 dispatch_source_.reset(new DispatchSourceMach( 54 dispatch_source_.reset(new base::DispatchSourceMach(
56 label.c_str(), server_port_.get(), ^{ ReceiveMessage(); })); 55 label.c_str(), server_port_.get(), ^{ ReceiveMessage(); }));
57 dispatch_source_->Resume(); 56 dispatch_source_->Resume();
58 57
59 return true; 58 return true;
60 } 59 }
61 60
62 pid_t XPCMessageServer::GetMessageSenderPID(IPCMessage request) { 61 pid_t XPCMessageServer::GetMessageSenderPID(IPCMessage request) {
63 audit_token_t token; 62 audit_token_t token;
64 xpc_dictionary_get_audit_token(request.xpc, &token); 63 xpc_dictionary_get_audit_token(request.xpc, &token);
65 // TODO(rsesek): In the 10.7 SDK, there's audit_token_to_pid(). 64 // TODO(rsesek): In the 10.7 SDK, there's audit_token_to_pid().
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 demuxer_->DemuxMessage(request); 117 demuxer_->DemuxMessage(request);
119 118
120 xpc_release(request.xpc); 119 xpc_release(request.xpc);
121 if (reply_message_) { 120 if (reply_message_) {
122 xpc_release(reply_message_); 121 xpc_release(reply_message_);
123 reply_message_ = NULL; 122 reply_message_ = NULL;
124 } 123 }
125 } 124 }
126 125
127 } // namespace sandbox 126 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/mac/xpc_message_server.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698