diff options
author | mark <mark@chromium.org> | 2015-10-20 11:36:13 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-10-20 18:37:12 +0000 |
commit | da902e18a4d31bc1d1534f85ab6cf30b4c4bcdfc (patch) | |
tree | d7e4440cd4ef743e4302ee7908a921be0e2b1ec2 /sandbox | |
parent | 220c73916470009f4b408fc15aa91fa5bf8d0df8 (diff) | |
download | chromium_src-da902e18a4d31bc1d1534f85ab6cf30b4c4bcdfc.zip chromium_src-da902e18a4d31bc1d1534f85ab6cf30b4c4bcdfc.tar.gz chromium_src-da902e18a4d31bc1d1534f85ab6cf30b4c4bcdfc.tar.bz2 |
mac: Make Mach port scopers better ScopedGenerics
Previously, Pass() did not work correctly for ScopedMachReceiveRight,
ScopedMachSendRight, or ScopedMachPortSet. These were defined as
subclasses of ScopedGeneric<> with appropriate traits types. They did
not have the full range of constructors made available by
ScopedGeneric<>, and their Pass() methods referred to their
ScopedGeneric<> superclass rather than their proper class types.
This changes these scopers to work as ScopedGeneric<> intends, with a
"using" or "typedef" declaration, so that names such as
ScopedMachReceiveRight actually refer to the same type as the underlying
ScopedGeneric<>. This allows Pass() and all other ScopedGeneric<>
functionality to work as intended.
Unfortunately, ScopedGeneric<> doesn't provide a type conversion
operator to the underlying wrapped type, so many use sites need to be
transformed to use the get() accessor. Many existing use sites already
used this accessor.
Review URL: https://codereview.chromium.org/1411523006
Cr-Commit-Position: refs/heads/master@{#355112}
Diffstat (limited to 'sandbox')
-rw-r--r-- | sandbox/mac/bootstrap_sandbox.h | 2 | ||||
-rw-r--r-- | sandbox/mac/launchd_interception_server.cc | 6 | ||||
-rw-r--r-- | sandbox/mac/xpc_message_server.cc | 2 |
3 files changed, 5 insertions, 5 deletions
diff --git a/sandbox/mac/bootstrap_sandbox.h b/sandbox/mac/bootstrap_sandbox.h index fa5f859..6e823a4 100644 --- a/sandbox/mac/bootstrap_sandbox.h +++ b/sandbox/mac/bootstrap_sandbox.h @@ -83,7 +83,7 @@ class SANDBOX_EXPORT BootstrapSandbox { const BootstrapSandboxPolicy* PolicyForProcess(pid_t pid) const; std::string server_bootstrap_name() const { return server_bootstrap_name_; } - mach_port_t real_bootstrap_port() const { return real_bootstrap_port_; } + mach_port_t real_bootstrap_port() const { return real_bootstrap_port_.get(); } private: BootstrapSandbox(); diff --git a/sandbox/mac/launchd_interception_server.cc b/sandbox/mac/launchd_interception_server.cc index f466e77..6ce61f6 100644 --- a/sandbox/mac/launchd_interception_server.cc +++ b/sandbox/mac/launchd_interception_server.cc @@ -44,12 +44,12 @@ bool LaunchdInterceptionServer::Initialize(mach_port_t server_receive_right) { return false; } sandbox_port_.reset(port); - if ((kr = mach_port_insert_right(task, sandbox_port_, sandbox_port_, - MACH_MSG_TYPE_MAKE_SEND) != KERN_SUCCESS)) { + if ((kr = mach_port_insert_right(task, sandbox_port_.get(), + sandbox_port_.get(), MACH_MSG_TYPE_MAKE_SEND) != KERN_SUCCESS)) { MACH_LOG(ERROR, kr) << "Failed to allocate dummy sandbox port send right."; return false; } - sandbox_send_port_.reset(sandbox_port_); + sandbox_send_port_.reset(sandbox_port_.get()); if (base::mac::IsOSYosemiteOrLater()) { message_server_.reset(new XPCMessageServer(this, server_receive_right)); diff --git a/sandbox/mac/xpc_message_server.cc b/sandbox/mac/xpc_message_server.cc index e161b5a..d811e5d 100644 --- a/sandbox/mac/xpc_message_server.cc +++ b/sandbox/mac/xpc_message_server.cc @@ -104,7 +104,7 @@ mach_port_t XPCMessageServer::GetServerPort() const { void XPCMessageServer::ReceiveMessage() { IPCMessage request; - int rv = xpc_pipe_receive(server_port_, &request.xpc); + int rv = xpc_pipe_receive(server_port_.get(), &request.xpc); if (rv) { LOG(ERROR) << "Failed to xpc_pipe_receive(): " << rv; return; |