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/gpu/gpu_child_thread.h" | 5 #include "content/gpu/gpu_child_thread.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
12 #include "base/threading/worker_pool.h" | 12 #include "base/threading/worker_pool.h" |
13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
14 #include "content/child/child_process.h" | 14 #include "content/child/child_process.h" |
15 #include "content/child/thread_safe_sender.h" | 15 #include "content/child/thread_safe_sender.h" |
16 #include "content/common/gpu/gpu_memory_buffer_factory.h" | 16 #include "content/common/gpu/gpu_memory_buffer_factory.h" |
17 #include "content/common/gpu/gpu_messages.h" | 17 #include "content/common/gpu/gpu_messages.h" |
18 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" | 18 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" |
19 #include "content/gpu/gpu_process_control_impl.h" | 19 #include "content/gpu/gpu_process_control_impl.h" |
20 #include "content/gpu/gpu_watchdog_thread.h" | 20 #include "content/gpu/gpu_watchdog_thread.h" |
21 #include "content/public/common/content_client.h" | 21 #include "content/public/common/content_client.h" |
22 #include "content/public/common/content_switches.h" | 22 #include "content/public/common/content_switches.h" |
23 #include "content/public/gpu/content_gpu_client.h" | 23 #include "content/public/gpu/content_gpu_client.h" |
24 #include "gpu/config/gpu_info_collector.h" | 24 #include "gpu/config/gpu_info_collector.h" |
25 #include "ipc/ipc_channel_handle.h" | 25 #include "ipc/ipc_channel_handle.h" |
26 #include "ipc/ipc_sync_message_filter.h" | 26 #include "ipc/ipc_sync_message_filter.h" |
27 #include "ui/gl/gl_implementation.h" | 27 #include "ui/gl/gl_implementation.h" |
28 #include "ui/gl/gpu_switching_manager.h" | 28 #include "ui/gl/gpu_switching_manager.h" |
| 29 #include "url/gurl.h" |
29 | 30 |
30 #if defined(USE_OZONE) | 31 #if defined(USE_OZONE) |
31 #include "ui/ozone/public/gpu_platform_support.h" | 32 #include "ui/ozone/public/gpu_platform_support.h" |
32 #include "ui/ozone/public/ozone_platform.h" | 33 #include "ui/ozone/public/ozone_platform.h" |
33 #endif | 34 #endif |
34 | 35 |
35 namespace content { | 36 namespace content { |
36 namespace { | 37 namespace { |
37 | 38 |
38 static base::LazyInstance<scoped_refptr<ThreadSafeSender> > | 39 static base::LazyInstance<scoped_refptr<ThreadSafeSender> > |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 | 275 |
275 // We don't need to pipe log messages if we are running the GPU thread in | 276 // We don't need to pipe log messages if we are running the GPU thread in |
276 // the browser process. | 277 // the browser process. |
277 if (!in_browser_process_) | 278 if (!in_browser_process_) |
278 logging::SetLogMessageHandler(GpuProcessLogMessageHandler); | 279 logging::SetLogMessageHandler(GpuProcessLogMessageHandler); |
279 | 280 |
280 // Defer creation of the render thread. This is to prevent it from handling | 281 // Defer creation of the render thread. This is to prevent it from handling |
281 // IPC messages before the sandbox has been enabled and all other necessary | 282 // IPC messages before the sandbox has been enabled and all other necessary |
282 // initialization has succeeded. | 283 // initialization has succeeded. |
283 gpu_channel_manager_.reset( | 284 gpu_channel_manager_.reset( |
284 new GpuChannelManager(channel(), watchdog_thread_.get(), | 285 new GpuChannelManager(this, channel(), watchdog_thread_.get(), |
285 base::ThreadTaskRunnerHandle::Get().get(), | 286 base::ThreadTaskRunnerHandle::Get().get(), |
286 ChildProcess::current()->io_task_runner(), | 287 ChildProcess::current()->io_task_runner(), |
287 ChildProcess::current()->GetShutDownEvent(), | 288 ChildProcess::current()->GetShutDownEvent(), |
288 sync_point_manager_, gpu_memory_buffer_factory_)); | 289 sync_point_manager_, gpu_memory_buffer_factory_)); |
289 | 290 |
290 #if defined(USE_OZONE) | 291 #if defined(USE_OZONE) |
291 ui::OzonePlatform::GetInstance() | 292 ui::OzonePlatform::GetInstance() |
292 ->GetGpuPlatformSupport() | 293 ->GetGpuPlatformSupport() |
293 ->OnChannelEstablished(this); | 294 ->OnChannelEstablished(this); |
294 #endif | 295 #endif |
295 } | 296 } |
296 | 297 |
297 void GpuChildThread::OnFinalize() { | 298 void GpuChildThread::OnFinalize() { |
298 // Quit the GPU process | 299 // Quit the GPU process |
299 base::MessageLoop::current()->QuitWhenIdle(); | 300 base::MessageLoop::current()->QuitWhenIdle(); |
300 } | 301 } |
301 | 302 |
302 void GpuChildThread::StopWatchdog() { | 303 void GpuChildThread::StopWatchdog() { |
303 if (watchdog_thread_.get()) { | 304 if (watchdog_thread_.get()) { |
304 watchdog_thread_->Stop(); | 305 watchdog_thread_->Stop(); |
305 } | 306 } |
306 } | 307 } |
307 | 308 |
| 309 void GpuChildThread::SetActiveURL(const std::string& url) { |
| 310 GetContentClient()->SetActiveURL(GURL(url)); |
| 311 } |
| 312 |
308 void GpuChildThread::OnCollectGraphicsInfo() { | 313 void GpuChildThread::OnCollectGraphicsInfo() { |
309 #if defined(OS_WIN) | 314 #if defined(OS_WIN) |
310 // GPU full info collection should only happen on un-sandboxed GPU process | 315 // GPU full info collection should only happen on un-sandboxed GPU process |
311 // or single process/in-process gpu mode on Windows. | 316 // or single process/in-process gpu mode on Windows. |
312 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 317 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
313 DCHECK(command_line->HasSwitch(switches::kDisableGpuSandbox) || | 318 DCHECK(command_line->HasSwitch(switches::kDisableGpuSandbox) || |
314 in_browser_process_); | 319 in_browser_process_); |
315 #endif // OS_WIN | 320 #endif // OS_WIN |
316 | 321 |
317 gpu::CollectInfoResult result = | 322 gpu::CollectInfoResult result = |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 | 404 |
400 void GpuChildThread::BindProcessControlRequest( | 405 void GpuChildThread::BindProcessControlRequest( |
401 mojo::InterfaceRequest<ProcessControl> request) { | 406 mojo::InterfaceRequest<ProcessControl> request) { |
402 DVLOG(1) << "GPU: Binding ProcessControl request"; | 407 DVLOG(1) << "GPU: Binding ProcessControl request"; |
403 DCHECK(process_control_); | 408 DCHECK(process_control_); |
404 process_control_bindings_.AddBinding(process_control_.get(), | 409 process_control_bindings_.AddBinding(process_control_.get(), |
405 std::move(request)); | 410 std::move(request)); |
406 } | 411 } |
407 | 412 |
408 } // namespace content | 413 } // namespace content |
OLD | NEW |