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/gpu/gpu_child_thread.h" | 5 #include "content/gpu/gpu_child_thread.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/threading/worker_pool.h" | 9 #include "base/threading/worker_pool.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 #include "content/child/child_process.h" | 11 #include "content/child/child_process.h" |
| 12 #include "content/child/thread_safe_sender.h" | 12 #include "content/child/thread_safe_sender.h" |
| 13 #include "content/common/gpu/gpu_messages.h" | 13 #include "content/common/gpu/gpu_messages.h" |
| 14 #include "content/gpu/gpu_watchdog_thread.h" | 14 #include "content/gpu/gpu_watchdog_thread.h" |
| 15 #include "content/public/common/content_client.h" | 15 #include "content/public/common/content_client.h" |
| 16 #include "content/public/common/content_switches.h" | 16 #include "content/public/common/content_switches.h" |
| 17 #include "gpu/config/gpu_info_collector.h" | 17 #include "gpu/config/gpu_info_collector.h" |
| 18 #include "ipc/ipc_channel_handle.h" | 18 #include "ipc/ipc_channel_handle.h" |
| 19 #include "ipc/ipc_sync_message_filter.h" | 19 #include "ipc/ipc_sync_message_filter.h" |
| 20 #include "ui/gl/gl_implementation.h" | 20 #include "ui/gl/gl_implementation.h" |
| 21 | 21 |
| 22 #if defined(USE_OZONE) | |
| 23 #include "ui/ozone/gpu/gpu_platform_support.h" | |
| 24 #endif | |
| 25 | |
| 22 namespace content { | 26 namespace content { |
| 23 namespace { | 27 namespace { |
| 24 | 28 |
| 25 static base::LazyInstance<scoped_refptr<ThreadSafeSender> > | 29 static base::LazyInstance<scoped_refptr<ThreadSafeSender> > |
| 26 g_thread_safe_sender = LAZY_INSTANCE_INITIALIZER; | 30 g_thread_safe_sender = LAZY_INSTANCE_INITIALIZER; |
| 27 | 31 |
| 28 bool GpuProcessLogMessageHandler(int severity, | 32 bool GpuProcessLogMessageHandler(int severity, |
| 29 const char* file, int line, | 33 const char* file, int line, |
| 30 size_t message_start, | 34 size_t message_start, |
| 31 const std::string& str) { | 35 const std::string& str) { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 // process. This could result in deadlock. | 97 // process. This could result in deadlock. |
| 94 DCHECK(!msg->is_sync()); | 98 DCHECK(!msg->is_sync()); |
| 95 | 99 |
| 96 return ChildThread::Send(msg); | 100 return ChildThread::Send(msg); |
| 97 } | 101 } |
| 98 | 102 |
| 99 bool GpuChildThread::OnControlMessageReceived(const IPC::Message& msg) { | 103 bool GpuChildThread::OnControlMessageReceived(const IPC::Message& msg) { |
| 100 bool handled = true; | 104 bool handled = true; |
| 101 IPC_BEGIN_MESSAGE_MAP(GpuChildThread, msg) | 105 IPC_BEGIN_MESSAGE_MAP(GpuChildThread, msg) |
| 102 IPC_MESSAGE_HANDLER(GpuMsg_Initialize, OnInitialize) | 106 IPC_MESSAGE_HANDLER(GpuMsg_Initialize, OnInitialize) |
| 107 IPC_MESSAGE_HANDLER(GpuMsg_InitializePlatformSupport, | |
| 108 OnInitializePlatformSupport) | |
| 103 IPC_MESSAGE_HANDLER(GpuMsg_CollectGraphicsInfo, OnCollectGraphicsInfo) | 109 IPC_MESSAGE_HANDLER(GpuMsg_CollectGraphicsInfo, OnCollectGraphicsInfo) |
| 104 IPC_MESSAGE_HANDLER(GpuMsg_GetVideoMemoryUsageStats, | 110 IPC_MESSAGE_HANDLER(GpuMsg_GetVideoMemoryUsageStats, |
| 105 OnGetVideoMemoryUsageStats) | 111 OnGetVideoMemoryUsageStats) |
| 106 IPC_MESSAGE_HANDLER(GpuMsg_Clean, OnClean) | 112 IPC_MESSAGE_HANDLER(GpuMsg_Clean, OnClean) |
| 107 IPC_MESSAGE_HANDLER(GpuMsg_Crash, OnCrash) | 113 IPC_MESSAGE_HANDLER(GpuMsg_Crash, OnCrash) |
| 108 IPC_MESSAGE_HANDLER(GpuMsg_Hang, OnHang) | 114 IPC_MESSAGE_HANDLER(GpuMsg_Hang, OnHang) |
| 109 IPC_MESSAGE_HANDLER(GpuMsg_DisableWatchdog, OnDisableWatchdog) | 115 IPC_MESSAGE_HANDLER(GpuMsg_DisableWatchdog, OnDisableWatchdog) |
| 110 IPC_MESSAGE_UNHANDLED(handled = false) | 116 IPC_MESSAGE_UNHANDLED(handled = false) |
| 111 IPC_END_MESSAGE_MAP() | 117 IPC_END_MESSAGE_MAP() |
| 112 | 118 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 // Defer creation of the render thread. This is to prevent it from handling | 153 // Defer creation of the render thread. This is to prevent it from handling |
| 148 // IPC messages before the sandbox has been enabled and all other necessary | 154 // IPC messages before the sandbox has been enabled and all other necessary |
| 149 // initialization has succeeded. | 155 // initialization has succeeded. |
| 150 gpu_channel_manager_.reset( | 156 gpu_channel_manager_.reset( |
| 151 new GpuChannelManager(GetRouter(), | 157 new GpuChannelManager(GetRouter(), |
| 152 watchdog_thread_.get(), | 158 watchdog_thread_.get(), |
| 153 ChildProcess::current()->io_message_loop_proxy(), | 159 ChildProcess::current()->io_message_loop_proxy(), |
| 154 ChildProcess::current()->GetShutDownEvent())); | 160 ChildProcess::current()->GetShutDownEvent())); |
| 155 } | 161 } |
| 156 | 162 |
| 163 void GpuChildThread::OnInitializePlatformSupport(int32 host_route_id) { | |
|
rjkroege
2014/06/16 21:38:49
MessageFilter might make this cleaner. Might let y
| |
| 164 #if defined(USE_OZONE) | |
| 165 ui::GpuPlatformSupport* platform_support = | |
| 166 ui::GpuPlatformSupport::Initialize(); | |
| 167 int gpu_route_id = gpu_channel_manager_->GenerateRouteID(); | |
| 168 gpu_channel_manager_->AddRoute(gpu_route_id, platform_support); | |
| 169 Send(new GpuHostMsg_PlatformSupportInitialized(host_route_id, gpu_route_id)); | |
| 170 platform_support->OnChannelEstablished(this, host_route_id); | |
| 171 #endif | |
| 172 } | |
| 173 | |
| 157 void GpuChildThread::StopWatchdog() { | 174 void GpuChildThread::StopWatchdog() { |
| 158 if (watchdog_thread_.get()) { | 175 if (watchdog_thread_.get()) { |
| 159 watchdog_thread_->Stop(); | 176 watchdog_thread_->Stop(); |
| 160 } | 177 } |
| 161 } | 178 } |
| 162 | 179 |
| 163 void GpuChildThread::OnCollectGraphicsInfo() { | 180 void GpuChildThread::OnCollectGraphicsInfo() { |
| 164 #if defined(OS_WIN) | 181 #if defined(OS_WIN) |
| 165 // GPU full info collection should only happen on un-sandboxed GPU process | 182 // GPU full info collection should only happen on un-sandboxed GPU process |
| 166 // or single process/in-process gpu mode on Windows. | 183 // or single process/in-process gpu mode on Windows. |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 238 // the future posting of tasks to the message loop. | 255 // the future posting of tasks to the message loop. |
| 239 if (watchdog_thread_->message_loop()) | 256 if (watchdog_thread_->message_loop()) |
| 240 watchdog_thread_->PostAcknowledge(); | 257 watchdog_thread_->PostAcknowledge(); |
| 241 // Prevent rearming. | 258 // Prevent rearming. |
| 242 watchdog_thread_->Stop(); | 259 watchdog_thread_->Stop(); |
| 243 } | 260 } |
| 244 } | 261 } |
| 245 | 262 |
| 246 } // namespace content | 263 } // namespace content |
| 247 | 264 |
| OLD | NEW |