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