| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/gpu/gpu_channel.h" | 5 #include "chrome/gpu/gpu_channel.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 GpuChannel::~GpuChannel() { | 32 GpuChannel::~GpuChannel() { |
| 33 } | 33 } |
| 34 | 34 |
| 35 void GpuChannel::OnChannelConnected(int32 peer_pid) { | 35 void GpuChannel::OnChannelConnected(int32 peer_pid) { |
| 36 if (!renderer_process_.Open(peer_pid)) { | 36 if (!renderer_process_.Open(peer_pid)) { |
| 37 NOTREACHED(); | 37 NOTREACHED(); |
| 38 } | 38 } |
| 39 } | 39 } |
| 40 | 40 |
| 41 void GpuChannel::OnMessageReceived(const IPC::Message& message) { | 41 bool GpuChannel::OnMessageReceived(const IPC::Message& message) { |
| 42 if (log_messages_) { | 42 if (log_messages_) { |
| 43 VLOG(1) << "received message @" << &message << " on channel @" << this | 43 VLOG(1) << "received message @" << &message << " on channel @" << this |
| 44 << " with type " << message.type(); | 44 << " with type " << message.type(); |
| 45 } | 45 } |
| 46 | 46 |
| 47 if (message.routing_id() == MSG_ROUTING_CONTROL) { | 47 if (message.routing_id() == MSG_ROUTING_CONTROL) |
| 48 OnControlMessageReceived(message); | 48 return OnControlMessageReceived(message); |
| 49 } else { | 49 |
| 50 // Fail silently if the GPU process has destroyed while the IPC message was | 50 // Fail silently if the GPU process has destroyed while the IPC message was |
| 51 // en-route. | 51 // en-route. |
| 52 router_.RouteMessage(message); | 52 return router_.RouteMessage(message); |
| 53 } | |
| 54 } | 53 } |
| 55 | 54 |
| 56 void GpuChannel::OnChannelError() { | 55 void GpuChannel::OnChannelError() { |
| 57 static_cast<GpuThread*>(ChildThread::current())->RemoveChannel(renderer_id_); | 56 static_cast<GpuThread*>(ChildThread::current())->RemoveChannel(renderer_id_); |
| 58 } | 57 } |
| 59 | 58 |
| 60 bool GpuChannel::Send(IPC::Message* message) { | 59 bool GpuChannel::Send(IPC::Message* message) { |
| 61 if (log_messages_) { | 60 if (log_messages_) { |
| 62 VLOG(1) << "sending message @" << message << " on channel @" << this | 61 VLOG(1) << "sending message @" << message << " on channel @" << this |
| 63 << " with type " << message->type(); | 62 << " with type " << message->type(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 87 // put into |stubs_|. Hence, do not walk |stubs_| here but instead remember | 86 // put into |stubs_|. Hence, do not walk |stubs_| here but instead remember |
| 88 // all |renderer_route_id|s this was called for and use them later. | 87 // all |renderer_route_id|s this was called for and use them later. |
| 89 destroyed_renderer_routes_.insert(renderer_route_id); | 88 destroyed_renderer_routes_.insert(renderer_route_id); |
| 90 } | 89 } |
| 91 | 90 |
| 92 bool GpuChannel::IsRenderViewGone(int32 renderer_route_id) { | 91 bool GpuChannel::IsRenderViewGone(int32 renderer_route_id) { |
| 93 return destroyed_renderer_routes_.count(renderer_route_id) > 0; | 92 return destroyed_renderer_routes_.count(renderer_route_id) > 0; |
| 94 } | 93 } |
| 95 #endif | 94 #endif |
| 96 | 95 |
| 97 void GpuChannel::OnControlMessageReceived(const IPC::Message& msg) { | 96 bool GpuChannel::OnControlMessageReceived(const IPC::Message& msg) { |
| 97 bool handled = true; |
| 98 IPC_BEGIN_MESSAGE_MAP(GpuChannel, msg) | 98 IPC_BEGIN_MESSAGE_MAP(GpuChannel, msg) |
| 99 IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateViewCommandBuffer, | 99 IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateViewCommandBuffer, |
| 100 OnCreateViewCommandBuffer) | 100 OnCreateViewCommandBuffer) |
| 101 IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateOffscreenCommandBuffer, | 101 IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateOffscreenCommandBuffer, |
| 102 OnCreateOffscreenCommandBuffer) | 102 OnCreateOffscreenCommandBuffer) |
| 103 IPC_MESSAGE_HANDLER(GpuChannelMsg_DestroyCommandBuffer, | 103 IPC_MESSAGE_HANDLER(GpuChannelMsg_DestroyCommandBuffer, |
| 104 OnDestroyCommandBuffer) | 104 OnDestroyCommandBuffer) |
| 105 IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateVideoDecoder, | 105 IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateVideoDecoder, |
| 106 OnCreateVideoDecoder) | 106 OnCreateVideoDecoder) |
| 107 IPC_MESSAGE_HANDLER(GpuChannelMsg_DestroyVideoDecoder, | 107 IPC_MESSAGE_HANDLER(GpuChannelMsg_DestroyVideoDecoder, |
| 108 OnDestroyVideoDecoder) | 108 OnDestroyVideoDecoder) |
| 109 IPC_MESSAGE_UNHANDLED_ERROR() | 109 IPC_MESSAGE_UNHANDLED(handled = false) |
| 110 IPC_END_MESSAGE_MAP() | 110 IPC_END_MESSAGE_MAP() |
| 111 DCHECK(handled); |
| 112 return handled; |
| 111 } | 113 } |
| 112 | 114 |
| 113 int GpuChannel::GenerateRouteID() { | 115 int GpuChannel::GenerateRouteID() { |
| 114 static int last_id = 0; | 116 static int last_id = 0; |
| 115 return ++last_id; | 117 return ++last_id; |
| 116 } | 118 } |
| 117 | 119 |
| 118 void GpuChannel::OnCreateViewCommandBuffer( | 120 void GpuChannel::OnCreateViewCommandBuffer( |
| 119 gfx::NativeViewId view_id, | 121 gfx::NativeViewId view_id, |
| 120 int32 render_view_id, | 122 int32 render_view_id, |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 #if defined(OS_POSIX) | 260 #if defined(OS_POSIX) |
| 259 int GpuChannel::GetRendererFileDescriptor() { | 261 int GpuChannel::GetRendererFileDescriptor() { |
| 260 int fd = -1; | 262 int fd = -1; |
| 261 if (channel_.get()) { | 263 if (channel_.get()) { |
| 262 fd = channel_->GetClientFileDescriptor(); | 264 fd = channel_->GetClientFileDescriptor(); |
| 263 } | 265 } |
| 264 return fd; | 266 return fd; |
| 265 } | 267 } |
| 266 #endif // defined(OS_POSIX) | 268 #endif // defined(OS_POSIX) |
| 267 | 269 |
| OLD | NEW |