| 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 dbc87e66d2371fe51f4be324a6c2df055ae6f826..6d23abca676402d3c2c067ea148fb12782613d28 100644
|
| --- a/content/browser/browser_io_surface_manager_mac.cc
|
| +++ b/content/browser/browser_io_surface_manager_mac.cc
|
| @@ -198,10 +198,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);
|
| @@ -211,10 +209,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!";
|
| @@ -229,29 +225,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->body.msgh_descriptor_count = 0;
|
| + 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(
|
| @@ -272,11 +269,21 @@ 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->body.msgh_descriptor_count = 0;
|
| + reply->result = false;
|
| + reply->io_surface_port.name = MACH_PORT_NULL;
|
| + reply->io_surface_port.disposition = 0;
|
| + reply->io_surface_port.type = 0;
|
| +
|
| IOSurfaceManagerToken token;
|
| static_assert(sizeof(request.token_name) == sizeof(token.name),
|
| "Mach message token size doesn't match expectation.");
|
| @@ -284,27 +291,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
|
|
|