| 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/renderer/gpu_channel_host.h" | 5 #include "chrome/renderer/gpu_channel_host.h" |
| 6 | 6 |
| 7 #include "chrome/common/child_process.h" | 7 #include "chrome/common/child_process.h" |
| 8 #include "chrome/common/gpu_messages.h" | 8 #include "chrome/common/gpu_messages.h" |
| 9 #include "chrome/renderer/command_buffer_proxy.h" | 9 #include "chrome/renderer/command_buffer_proxy.h" |
| 10 #include "chrome/renderer/gpu_video_service_host.h" |
| 10 | 11 |
| 11 GpuChannelHost::GpuChannelHost() : state_(UNCONNECTED) { | 12 GpuChannelHost::GpuChannelHost() : state_(UNCONNECTED) { |
| 12 } | 13 } |
| 13 | 14 |
| 14 GpuChannelHost::~GpuChannelHost() { | 15 GpuChannelHost::~GpuChannelHost() { |
| 15 } | 16 } |
| 16 | 17 |
| 17 void GpuChannelHost::Connect(const std::string& channel_name) { | 18 void GpuChannelHost::Connect(const std::string& channel_name) { |
| 18 // Open a channel to the GPU process. | 19 // Open a channel to the GPU process. |
| 19 channel_.reset(new IPC::SyncChannel( | 20 channel_.reset(new IPC::SyncChannel( |
| 20 channel_name, IPC::Channel::MODE_CLIENT, this, NULL, | 21 channel_name, IPC::Channel::MODE_CLIENT, this, NULL, |
| 21 ChildProcess::current()->io_message_loop(), true, | 22 ChildProcess::current()->io_message_loop(), true, |
| 22 ChildProcess::current()->GetShutDownEvent())); | 23 ChildProcess::current()->GetShutDownEvent())); |
| 23 | 24 |
| 24 // It is safe to send IPC messages before the channel completes the connection | 25 // It is safe to send IPC messages before the channel completes the connection |
| 25 // and receives the hello message from the GPU process. The messages get | 26 // and receives the hello message from the GPU process. The messages get |
| 26 // cached. | 27 // cached. |
| 27 state_ = CONNECTED; | 28 state_ = CONNECTED; |
| 28 } | 29 } |
| 29 | 30 |
| 30 void GpuChannelHost::OnMessageReceived(const IPC::Message& message) { | 31 void GpuChannelHost::OnMessageReceived(const IPC::Message& message) { |
| 31 DCHECK(message.routing_id() != MSG_ROUTING_CONTROL); | 32 DCHECK(message.routing_id() != MSG_ROUTING_CONTROL); |
| 32 if (!router_.RouteMessage(message)) { | 33 if (!router_.RouteMessage(message)) { |
| 33 NOTREACHED() << "GpuChannelHost failed to route message"; | 34 NOTREACHED() << "GpuChannelHost failed to route message"; |
| 34 } | 35 } |
| 35 } | 36 } |
| 36 | 37 |
| 37 void GpuChannelHost::OnChannelConnected(int32 peer_pid) { | 38 void GpuChannelHost::OnChannelConnected(int32 peer_pid) { |
| 39 GpuVideoServiceHost::get()->OnGpuChannelConnected(this, |
| 40 &router_, |
| 41 channel_.get()); |
| 38 } | 42 } |
| 39 | 43 |
| 40 void GpuChannelHost::OnChannelError() { | 44 void GpuChannelHost::OnChannelError() { |
| 41 state_ = LOST; | 45 state_ = LOST; |
| 42 | 46 |
| 43 // Channel is invalid and will be reinitialized if this host is requested | 47 // Channel is invalid and will be reinitialized if this host is requested |
| 44 // again. | 48 // again. |
| 45 channel_.reset(); | 49 channel_.reset(); |
| 46 | 50 |
| 47 // Inform all the proxies that an error has occured. This will be reported via | 51 // Inform all the proxies that an error has occured. This will be reported via |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 int route_id = command_buffer->route_id(); | 131 int route_id = command_buffer->route_id(); |
| 128 if (proxies_.find(command_buffer->route_id()) != proxies_.end()) { | 132 if (proxies_.find(command_buffer->route_id()) != proxies_.end()) { |
| 129 proxies_.erase(route_id); | 133 proxies_.erase(route_id); |
| 130 router_.RemoveRoute(route_id); | 134 router_.RemoveRoute(route_id); |
| 131 } | 135 } |
| 132 | 136 |
| 133 delete command_buffer; | 137 delete command_buffer; |
| 134 #endif | 138 #endif |
| 135 } | 139 } |
| 136 | 140 |
| OLD | NEW |