Chromium Code Reviews| Index: content/browser/browser_io_surface_manager_mac.cc |
| diff --git a/content/browser/browser_io_surface_manager_mac.cc b/content/browser/browser_io_surface_manager_mac.cc |
| index 519b48c684ad00058f38b6bf4dbcd78b895572f9..f61b3df756f3ffadbbd29d2fc99881405ea467fe 100644 |
| --- a/content/browser/browser_io_surface_manager_mac.cc |
| +++ b/content/browser/browser_io_surface_manager_mac.cc |
| @@ -199,10 +199,8 @@ void BrowserIOSurfaceManager::HandleRequest() { |
| switch (request.msg.header.msgh_id) { |
| case IOSurfaceManagerHostMsg_RegisterIOSurface::ID: |
| - if (!HandleRegisterIOSurfaceRequest(request.msg.register_io_surface, |
| - &reply.register_io_surface)) { |
| - return; |
| - } |
| + HandleRegisterIOSurfaceRequest(request.msg.register_io_surface, |
| + &reply.register_io_surface); |
| break; |
| case IOSurfaceManagerHostMsg_UnregisterIOSurface::ID: |
| HandleUnregisterIOSurfaceRequest(request.msg.unregister_io_surface); |
| @@ -212,10 +210,8 @@ void BrowserIOSurfaceManager::HandleRequest() { |
| // process. |
| return; |
| case IOSurfaceManagerHostMsg_AcquireIOSurface::ID: |
| - if (!HandleAcquireIOSurfaceRequest(request.msg.acquire_io_surface, |
| - &reply.acquire_io_surface)) { |
| - return; |
| - } |
| + HandleAcquireIOSurfaceRequest(request.msg.acquire_io_surface, |
| + &reply.acquire_io_surface); |
| break; |
| default: |
| LOG(ERROR) << "Unknown message received!"; |
| @@ -230,29 +226,30 @@ void BrowserIOSurfaceManager::HandleRequest() { |
| } |
| } |
| -bool BrowserIOSurfaceManager::HandleRegisterIOSurfaceRequest( |
| +void BrowserIOSurfaceManager::HandleRegisterIOSurfaceRequest( |
| const IOSurfaceManagerHostMsg_RegisterIOSurface& request, |
| IOSurfaceManagerMsg_RegisterIOSurfaceReply* reply) { |
| base::AutoLock lock(lock_); |
| + reply->header.msgh_bits = MACH_MSGH_BITS_REMOTE(request.header.msgh_bits); |
| + reply->header.msgh_remote_port = request.header.msgh_remote_port; |
| + reply->header.msgh_size = sizeof(*reply); |
| + reply->result = false; |
| + |
| IOSurfaceManagerToken token; |
| static_assert(sizeof(request.token_name) == sizeof(token.name), |
| "Mach message token size doesn't match expectation."); |
| token.SetName(request.token_name); |
| if (token.IsZero() || token != gpu_process_token_) { |
| LOG(ERROR) << "Illegal message from non-GPU process!"; |
| - return false; |
| + return; |
| } |
| IOSurfaceMapKey key(IOSurfaceId(request.io_surface_id), request.client_id); |
| io_surfaces_.add(key, make_scoped_ptr(new base::mac::ScopedMachSendRight( |
| request.io_surface_port.name))); |
| - reply->header.msgh_bits = MACH_MSGH_BITS_REMOTE(request.header.msgh_bits); |
| - reply->header.msgh_remote_port = request.header.msgh_remote_port; |
| - reply->header.msgh_size = sizeof(*reply); |
| reply->result = true; |
| - return true; |
| } |
| bool BrowserIOSurfaceManager::HandleUnregisterIOSurfaceRequest( |
| @@ -273,11 +270,17 @@ bool BrowserIOSurfaceManager::HandleUnregisterIOSurfaceRequest( |
| return true; |
| } |
| -bool BrowserIOSurfaceManager::HandleAcquireIOSurfaceRequest( |
| +void BrowserIOSurfaceManager::HandleAcquireIOSurfaceRequest( |
| const IOSurfaceManagerHostMsg_AcquireIOSurface& request, |
| IOSurfaceManagerMsg_AcquireIOSurfaceReply* reply) { |
| base::AutoLock lock(lock_); |
| + reply->header.msgh_bits = |
| + MACH_MSGH_BITS_REMOTE(request.header.msgh_bits) | MACH_MSGH_BITS_COMPLEX; |
| + reply->header.msgh_remote_port = request.header.msgh_remote_port; |
| + reply->header.msgh_size = sizeof(*reply); |
| + reply->result = false; |
|
reveman
2015/09/18 18:22:30
Request: This is not new to this patch but can you
ccameron
2015/09/18 18:36:00
Done. Also changed Register reply to set body.* to
reveman
2015/09/18 18:47:48
Ah, I guess we should really be doing a bzero(repl
|
| + |
| IOSurfaceManagerToken token; |
| static_assert(sizeof(request.token_name) == sizeof(token.name), |
| "Mach message token size doesn't match expectation."); |
| @@ -285,27 +288,22 @@ bool BrowserIOSurfaceManager::HandleAcquireIOSurfaceRequest( |
| auto child_process_id_it = child_process_ids_.find(token); |
| if (child_process_id_it == child_process_ids_.end()) { |
| LOG(ERROR) << "Illegal message from non-child process!"; |
| - return false; |
| + return; |
| } |
| - reply->header.msgh_bits = |
| - MACH_MSGH_BITS_REMOTE(request.header.msgh_bits) | MACH_MSGH_BITS_COMPLEX; |
| - reply->header.msgh_remote_port = request.header.msgh_remote_port; |
| - reply->header.msgh_size = sizeof(*reply); |
| - |
| + reply->result = true; |
| IOSurfaceMapKey key(IOSurfaceId(request.io_surface_id), |
| child_process_id_it->second); |
| auto it = io_surfaces_.find(key); |
| if (it == io_surfaces_.end()) { |
| LOG(ERROR) << "Invalid Id for IOSurface " << request.io_surface_id; |
| - return true; |
| + return; |
| } |
| reply->body.msgh_descriptor_count = 1; |
| reply->io_surface_port.name = it->second->get(); |
| reply->io_surface_port.disposition = MACH_MSG_TYPE_COPY_SEND; |
| reply->io_surface_port.type = MACH_MSG_PORT_DESCRIPTOR; |
| - return true; |
| } |
| } // namespace content |