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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 | 240 |
241 int route_id = command_buffer->GetRouteID(); | 241 int route_id = command_buffer->GetRouteID(); |
242 Send(new GpuChannelMsg_DestroyCommandBuffer(route_id)); | 242 Send(new GpuChannelMsg_DestroyCommandBuffer(route_id)); |
243 RemoveRoute(route_id); | 243 RemoveRoute(route_id); |
244 | 244 |
245 AutoLock lock(context_lock_); | 245 AutoLock lock(context_lock_); |
246 proxies_.erase(route_id); | 246 proxies_.erase(route_id); |
247 delete command_buffer; | 247 delete command_buffer; |
248 } | 248 } |
249 | 249 |
| 250 void GpuChannelHost::DestroyChannel() { |
| 251 // channel_ must be destroyed on the main thread. |
| 252 if (channel_.get() && !factory_->IsMainThread()) |
| 253 factory_->GetMainLoop()->DeleteSoon(FROM_HERE, channel_.release()); |
| 254 channel_.reset(); |
| 255 } |
| 256 |
250 void GpuChannelHost::AddRoute( | 257 void GpuChannelHost::AddRoute( |
251 int route_id, base::WeakPtr<IPC::Listener> listener) { | 258 int route_id, base::WeakPtr<IPC::Listener> listener) { |
252 DCHECK(MessageLoopProxy::current().get()); | 259 DCHECK(MessageLoopProxy::current().get()); |
253 | 260 |
254 scoped_refptr<base::MessageLoopProxy> io_loop = factory_->GetIOLoopProxy(); | 261 scoped_refptr<base::MessageLoopProxy> io_loop = factory_->GetIOLoopProxy(); |
255 io_loop->PostTask(FROM_HERE, | 262 io_loop->PostTask(FROM_HERE, |
256 base::Bind(&GpuChannelHost::MessageFilter::AddRoute, | 263 base::Bind(&GpuChannelHost::MessageFilter::AddRoute, |
257 channel_filter_.get(), route_id, listener, | 264 channel_filter_.get(), route_id, listener, |
258 MessageLoopProxy::current())); | 265 MessageLoopProxy::current())); |
259 } | 266 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 | 335 |
329 int32 GpuChannelHost::ReserveGpuMemoryBufferId() { | 336 int32 GpuChannelHost::ReserveGpuMemoryBufferId() { |
330 return next_gpu_memory_buffer_id_.GetNext(); | 337 return next_gpu_memory_buffer_id_.GetNext(); |
331 } | 338 } |
332 | 339 |
333 int32 GpuChannelHost::GenerateRouteID() { | 340 int32 GpuChannelHost::GenerateRouteID() { |
334 return next_route_id_.GetNext(); | 341 return next_route_id_.GetNext(); |
335 } | 342 } |
336 | 343 |
337 GpuChannelHost::~GpuChannelHost() { | 344 GpuChannelHost::~GpuChannelHost() { |
338 // channel_ must be destroyed on the main thread. | 345 DestroyChannel(); |
339 if (!factory_->IsMainThread()) | |
340 factory_->GetMainLoop()->DeleteSoon(FROM_HERE, channel_.release()); | |
341 } | 346 } |
342 | 347 |
343 | |
344 GpuChannelHost::MessageFilter::MessageFilter() | 348 GpuChannelHost::MessageFilter::MessageFilter() |
345 : lost_(false) { | 349 : lost_(false) { |
346 } | 350 } |
347 | 351 |
348 GpuChannelHost::MessageFilter::~MessageFilter() {} | 352 GpuChannelHost::MessageFilter::~MessageFilter() {} |
349 | 353 |
350 void GpuChannelHost::MessageFilter::AddRoute( | 354 void GpuChannelHost::MessageFilter::AddRoute( |
351 int route_id, | 355 int route_id, |
352 base::WeakPtr<IPC::Listener> listener, | 356 base::WeakPtr<IPC::Listener> listener, |
353 scoped_refptr<MessageLoopProxy> loop) { | 357 scoped_refptr<MessageLoopProxy> loop) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 | 410 |
407 listeners_.clear(); | 411 listeners_.clear(); |
408 } | 412 } |
409 | 413 |
410 bool GpuChannelHost::MessageFilter::IsLost() const { | 414 bool GpuChannelHost::MessageFilter::IsLost() const { |
411 AutoLock lock(lock_); | 415 AutoLock lock(lock_); |
412 return lost_; | 416 return lost_; |
413 } | 417 } |
414 | 418 |
415 } // namespace content | 419 } // namespace content |
OLD | NEW |