From da902e18a4d31bc1d1534f85ab6cf30b4c4bcdfc Mon Sep 17 00:00:00 2001 From: mark Date: Tue, 20 Oct 2015 11:36:13 -0700 Subject: 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} --- content/child/child_io_surface_manager_mac.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'content/child') diff --git a/content/child/child_io_surface_manager_mac.cc b/content/child/child_io_surface_manager_mac.cc index 883defe..063fe4c 100644 --- a/content/child/child_io_surface_manager_mac.cc +++ b/content/child/child_io_surface_manager_mac.cc @@ -45,12 +45,12 @@ bool ChildIOSurfaceManager::RegisterIOSurface(IOSurfaceId io_surface_id, data.request.header.msgh_bits = MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND, MACH_MSG_TYPE_MAKE_SEND_ONCE) | MACH_MSGH_BITS_COMPLEX; - data.request.header.msgh_remote_port = service_port_; + data.request.header.msgh_remote_port = service_port_.get(); data.request.header.msgh_local_port = reply_port; data.request.header.msgh_size = sizeof(data.request); data.request.header.msgh_id = IOSurfaceManagerHostMsg_RegisterIOSurface::ID; data.request.body.msgh_descriptor_count = 1; - data.request.io_surface_port.name = scoped_io_surface_right; + data.request.io_surface_port.name = scoped_io_surface_right.get(); data.request.io_surface_port.disposition = MACH_MSG_TYPE_COPY_SEND; data.request.io_surface_port.type = MACH_MSG_PORT_DESCRIPTOR; data.request.io_surface_id = io_surface_id.id; @@ -75,7 +75,7 @@ void ChildIOSurfaceManager::UnregisterIOSurface(IOSurfaceId io_surface_id, IOSurfaceManagerHostMsg_UnregisterIOSurface request = {{0}}; request.header.msgh_bits = MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND, 0); - request.header.msgh_remote_port = service_port_; + request.header.msgh_remote_port = service_port_.get(); request.header.msgh_local_port = MACH_PORT_NULL; request.header.msgh_size = sizeof(request); request.header.msgh_id = IOSurfaceManagerHostMsg_UnregisterIOSurface::ID; @@ -114,7 +114,7 @@ IOSurfaceRef ChildIOSurfaceManager::AcquireIOSurface( } data = {{{0}}}; data.request.header.msgh_bits = MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND, MACH_MSG_TYPE_MAKE_SEND_ONCE); - data.request.header.msgh_remote_port = service_port_; + data.request.header.msgh_remote_port = service_port_.get(); data.request.header.msgh_local_port = reply_port; data.request.header.msgh_size = sizeof(data.request); data.request.header.msgh_id = IOSurfaceManagerHostMsg_AcquireIOSurface::ID; @@ -137,7 +137,7 @@ IOSurfaceRef ChildIOSurfaceManager::AcquireIOSurface( base::mac::ScopedMachSendRight scoped_io_surface_right( data.reply.msg.io_surface_port.name); - return IOSurfaceLookupFromMachPort(scoped_io_surface_right); + return IOSurfaceLookupFromMachPort(scoped_io_surface_right.get()); } ChildIOSurfaceManager::ChildIOSurfaceManager() {} -- cgit v1.1