Chromium Code Reviews| 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/atomic_sequence_num.h" | 9 #include "base/atomic_sequence_num.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/posix/eintr_wrapper.h" | 12 #include "base/posix/eintr_wrapper.h" |
| 13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 14 #include "base/thread_task_runner_handle.h" | 14 #include "base/thread_task_runner_handle.h" |
| 15 #include "base/threading/thread_restrictions.h" | 15 #include "base/threading/thread_restrictions.h" |
| 16 #include "base/trace_event/trace_event.h" | 16 #include "base/trace_event/trace_event.h" |
| 17 #include "content/common/gpu/client/command_buffer_proxy_impl.h" | 17 #include "content/common/gpu/client/command_buffer_proxy_impl.h" |
| 18 #include "content/common/gpu/client/gpu_jpeg_decode_accelerator_host.h" | 18 #include "content/common/gpu/client/gpu_jpeg_decode_accelerator_host.h" |
| 19 #include "content/common/gpu/gpu_messages.h" | 19 #include "content/common/gpu/gpu_messages.h" |
| 20 #include "ipc/ipc_sync_message_filter.h" | 20 #include "ipc/ipc_sync_message_filter.h" |
| 21 #include "url/gurl.h" | 21 #include "url/gurl.h" |
| 22 | 22 |
| 23 #if defined(OS_WIN) || defined(OS_MACOSX) | 23 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 24 #include "content/public/common/sandbox_init.h" | 24 #include "content/public/common/sandbox_init.h" |
| 25 #include "ui/base/window_resize_helper.h" | |
| 25 #endif | 26 #endif |
| 26 | 27 |
| 27 using base::AutoLock; | 28 using base::AutoLock; |
| 28 | 29 |
| 29 namespace content { | 30 namespace content { |
| 30 namespace { | 31 namespace { |
| 31 | 32 |
| 32 // Global atomic to generate unique transfer buffer IDs. | 33 // Global atomic to generate unique transfer buffer IDs. |
| 33 base::StaticAtomicSequenceNumber g_next_transfer_buffer_id; | 34 base::StaticAtomicSequenceNumber g_next_transfer_buffer_id; |
| 34 | 35 |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 310 void GpuChannelHost::DestroyChannel() { | 311 void GpuChannelHost::DestroyChannel() { |
| 311 DCHECK(factory_->IsMainThread()); | 312 DCHECK(factory_->IsMainThread()); |
| 312 AutoLock lock(context_lock_); | 313 AutoLock lock(context_lock_); |
| 313 channel_.reset(); | 314 channel_.reset(); |
| 314 } | 315 } |
| 315 | 316 |
| 316 void GpuChannelHost::AddRoute( | 317 void GpuChannelHost::AddRoute( |
| 317 int route_id, base::WeakPtr<IPC::Listener> listener) { | 318 int route_id, base::WeakPtr<IPC::Listener> listener) { |
| 318 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner = | 319 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner = |
| 319 factory_->GetIOThreadTaskRunner(); | 320 factory_->GetIOThreadTaskRunner(); |
| 321 | |
| 322 #if defined(OS_MACOSX) || defined(OS_WIN) | |
| 323 scoped_refptr<base::SingleThreadTaskRunner> thread_task_runner; | |
| 324 if (factory_->IsMainThread()) { | |
| 325 // If we're adding a route to the main UI thread, we need to use the | |
| 326 // WindowResizeHelper's task runner, otherwise Gpu Channel messages will be | |
| 327 // blocked during a resize and we won't recieve the swap complete signal. | |
| 328 thread_task_runner = ui::WindowResizeHelper::Get()->task_runner(); | |
|
piman
2015/12/11 07:53:12
This code (GpuChannelHost) is used by both the ren
ericrk
2015/12/15 00:25:03
done - good point - was thinking that was what IsM
| |
| 329 } else { | |
| 330 thread_task_runner = base::ThreadTaskRunnerHandle::Get(); | |
| 331 } | |
| 332 #else | |
| 333 scoped_refptr<base::SingleThreadTaskRunner> thread_task_runner = | |
| 334 base::ThreadTaskRunnerHandle::Get(); | |
| 335 #endif | |
| 336 | |
| 320 io_task_runner->PostTask(FROM_HERE, | 337 io_task_runner->PostTask(FROM_HERE, |
| 321 base::Bind(&GpuChannelHost::MessageFilter::AddRoute, | 338 base::Bind(&GpuChannelHost::MessageFilter::AddRoute, |
| 322 channel_filter_.get(), route_id, listener, | 339 channel_filter_.get(), route_id, listener, |
| 323 base::ThreadTaskRunnerHandle::Get())); | 340 thread_task_runner)); |
| 324 } | 341 } |
| 325 | 342 |
| 326 void GpuChannelHost::RemoveRoute(int route_id) { | 343 void GpuChannelHost::RemoveRoute(int route_id) { |
| 327 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner = | 344 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner = |
| 328 factory_->GetIOThreadTaskRunner(); | 345 factory_->GetIOThreadTaskRunner(); |
| 329 io_task_runner->PostTask( | 346 io_task_runner->PostTask( |
| 330 FROM_HERE, base::Bind(&GpuChannelHost::MessageFilter::RemoveRoute, | 347 FROM_HERE, base::Bind(&GpuChannelHost::MessageFilter::RemoveRoute, |
| 331 channel_filter_.get(), route_id)); | 348 channel_filter_.get(), route_id)); |
| 332 } | 349 } |
| 333 | 350 |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 527 | 544 |
| 528 listeners_.clear(); | 545 listeners_.clear(); |
| 529 } | 546 } |
| 530 | 547 |
| 531 bool GpuChannelHost::MessageFilter::IsLost() const { | 548 bool GpuChannelHost::MessageFilter::IsLost() const { |
| 532 AutoLock lock(lock_); | 549 AutoLock lock(lock_); |
| 533 return lost_; | 550 return lost_; |
| 534 } | 551 } |
| 535 | 552 |
| 536 } // namespace content | 553 } // namespace content |
| OLD | NEW |