OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/common/gpu/client/gpu_channel_host.h" | 5 #include "content/common/gpu/client/gpu_channel_host.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
11 #include "base/threading/thread_restrictions.h" | 11 #include "base/threading/thread_restrictions.h" |
12 #include "content/common/gpu/client/command_buffer_proxy_impl.h" | 12 #include "content/common/gpu/client/command_buffer_proxy_impl.h" |
13 #include "content/common/gpu/gpu_messages.h" | 13 #include "content/common/gpu/gpu_messages.h" |
14 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
15 #include "ipc/ipc_sync_message_filter.h" | 15 #include "ipc/ipc_sync_message_filter.h" |
16 | 16 |
17 using base::AutoLock; | 17 using base::AutoLock; |
18 using base::MessageLoopProxy; | 18 using base::MessageLoopProxy; |
19 | 19 |
| 20 namespace content { |
| 21 |
20 GpuListenerInfo::GpuListenerInfo() {} | 22 GpuListenerInfo::GpuListenerInfo() {} |
21 | 23 |
22 GpuListenerInfo::~GpuListenerInfo() {} | 24 GpuListenerInfo::~GpuListenerInfo() {} |
23 | 25 |
24 GpuChannelHost::GpuChannelHost( | 26 GpuChannelHost::GpuChannelHost( |
25 GpuChannelHostFactory* factory, int gpu_host_id, int client_id) | 27 GpuChannelHostFactory* factory, int gpu_host_id, int client_id) |
26 : factory_(factory), | 28 : factory_(factory), |
27 client_id_(client_id), | 29 client_id_(client_id), |
28 gpu_host_id_(gpu_host_id), | 30 gpu_host_id_(gpu_host_id), |
29 state_(kUnconnected) { | 31 state_(kUnconnected) { |
(...skipping 20 matching lines...) Expand all Loading... |
50 // Install the filter last, because we intercept all leftover | 52 // Install the filter last, because we intercept all leftover |
51 // messages. | 53 // messages. |
52 channel_->AddFilter(channel_filter_.get()); | 54 channel_->AddFilter(channel_filter_.get()); |
53 | 55 |
54 // It is safe to send IPC messages before the channel completes the connection | 56 // It is safe to send IPC messages before the channel completes the connection |
55 // and receives the hello message from the GPU process. The messages get | 57 // and receives the hello message from the GPU process. The messages get |
56 // cached. | 58 // cached. |
57 state_ = kConnected; | 59 state_ = kConnected; |
58 } | 60 } |
59 | 61 |
60 void GpuChannelHost::set_gpu_info(const content::GPUInfo& gpu_info) { | 62 void GpuChannelHost::set_gpu_info(const GPUInfo& gpu_info) { |
61 gpu_info_ = gpu_info; | 63 gpu_info_ = gpu_info; |
62 } | 64 } |
63 | 65 |
64 void GpuChannelHost::SetStateLost() { | 66 void GpuChannelHost::SetStateLost() { |
65 state_ = kLost; | 67 state_ = kLost; |
66 } | 68 } |
67 | 69 |
68 const content::GPUInfo& GpuChannelHost::gpu_info() const { | 70 const GPUInfo& GpuChannelHost::gpu_info() const { |
69 return gpu_info_; | 71 return gpu_info_; |
70 } | 72 } |
71 | 73 |
72 void GpuChannelHost::OnChannelError() { | 74 void GpuChannelHost::OnChannelError() { |
73 state_ = kLost; | 75 state_ = kLost; |
74 | 76 |
75 // Channel is invalid and will be reinitialized if this host is requested | 77 // Channel is invalid and will be reinitialized if this host is requested |
76 // again. | 78 // again. |
77 channel_.reset(); | 79 channel_.reset(); |
78 } | 80 } |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 Send(new GpuChannelMsg_DestroyCommandBuffer(route_id)); | 210 Send(new GpuChannelMsg_DestroyCommandBuffer(route_id)); |
209 // Check the proxy has not already been removed after a channel error. | 211 // Check the proxy has not already been removed after a channel error. |
210 if (proxies_.find(route_id) != proxies_.end()) | 212 if (proxies_.find(route_id) != proxies_.end()) |
211 proxies_.erase(route_id); | 213 proxies_.erase(route_id); |
212 RemoveRoute(route_id); | 214 RemoveRoute(route_id); |
213 delete command_buffer; | 215 delete command_buffer; |
214 #endif | 216 #endif |
215 } | 217 } |
216 | 218 |
217 bool GpuChannelHost::CollectRenderingStatsForSurface( | 219 bool GpuChannelHost::CollectRenderingStatsForSurface( |
218 int surface_id, content::GpuRenderingStats* stats) { | 220 int surface_id, GpuRenderingStats* stats) { |
219 TRACE_EVENT0("gpu", "GpuChannelHost::CollectRenderingStats"); | 221 TRACE_EVENT0("gpu", "GpuChannelHost::CollectRenderingStats"); |
220 | 222 |
221 return Send(new GpuChannelMsg_CollectRenderingStatsForSurface(surface_id, | 223 return Send(new GpuChannelMsg_CollectRenderingStatsForSurface(surface_id, |
222 stats)); | 224 stats)); |
223 } | 225 } |
224 | 226 |
225 void GpuChannelHost::AddRoute( | 227 void GpuChannelHost::AddRoute( |
226 int route_id, base::WeakPtr<IPC::Listener> listener) { | 228 int route_id, base::WeakPtr<IPC::Listener> listener) { |
227 DCHECK(MessageLoopProxy::current()); | 229 DCHECK(MessageLoopProxy::current()); |
228 | 230 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 it++) { | 310 it++) { |
309 const GpuListenerInfo& info = it->second; | 311 const GpuListenerInfo& info = it->second; |
310 info.loop->PostTask( | 312 info.loop->PostTask( |
311 FROM_HERE, | 313 FROM_HERE, |
312 base::Bind(&IPC::Listener::OnChannelError, info.listener)); | 314 base::Bind(&IPC::Listener::OnChannelError, info.listener)); |
313 } | 315 } |
314 | 316 |
315 listeners_.clear(); | 317 listeners_.clear(); |
316 } | 318 } |
317 | 319 |
318 | 320 } // namespace content |
OLD | NEW |