| 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/establish_channel_params.h" |
| 17 #include "content/common/gpu/gpu_browser_messages.h" |
| 16 #include "content/common/gpu/gpu_memory_buffer_factory.h" | 18 #include "content/common/gpu/gpu_memory_buffer_factory.h" |
| 17 #include "content/common/gpu/gpu_messages.h" | |
| 18 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" | 19 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" |
| 19 #include "content/gpu/gpu_process_control_impl.h" | 20 #include "content/gpu/gpu_process_control_impl.h" |
| 20 #include "content/gpu/gpu_watchdog_thread.h" | 21 #include "content/gpu/gpu_watchdog_thread.h" |
| 21 #include "content/public/common/content_client.h" | 22 #include "content/public/common/content_client.h" |
| 22 #include "content/public/common/content_switches.h" | 23 #include "content/public/common/content_switches.h" |
| 23 #include "gpu/config/gpu_info_collector.h" | 24 #include "gpu/config/gpu_info_collector.h" |
| 24 #include "ipc/ipc_channel_handle.h" | 25 #include "ipc/ipc_channel_handle.h" |
| 25 #include "ipc/ipc_sync_message_filter.h" | 26 #include "ipc/ipc_sync_message_filter.h" |
| 26 #include "ui/gl/gl_implementation.h" | 27 #include "ui/gl/gl_implementation.h" |
| 27 #include "ui/gl/gpu_switching_manager.h" | 28 #include "ui/gl/gpu_switching_manager.h" |
| 28 | 29 |
| 29 #if defined(USE_OZONE) | 30 #if defined(USE_OZONE) |
| 30 #include "ui/ozone/public/gpu_platform_support.h" | 31 #include "ui/ozone/public/gpu_platform_support.h" |
| 31 #include "ui/ozone/public/ozone_platform.h" | 32 #include "ui/ozone/public/ozone_platform.h" |
| 32 #endif | 33 #endif |
| 33 | 34 |
| 34 namespace content { | 35 namespace content { |
| 35 namespace { | 36 namespace { |
| 36 | 37 |
| 37 static base::LazyInstance<scoped_refptr<ThreadSafeSender> > | 38 static base::LazyInstance<scoped_refptr<ThreadSafeSender> > |
| 38 g_thread_safe_sender = LAZY_INSTANCE_INITIALIZER; | 39 g_thread_safe_sender = LAZY_INSTANCE_INITIALIZER; |
| 39 | 40 |
| 40 bool GpuProcessLogMessageHandler(int severity, | 41 bool GpuProcessLogMessageHandler(int severity, |
| 41 const char* file, int line, | 42 const char* file, int line, |
| 42 size_t message_start, | 43 size_t message_start, |
| 43 const std::string& str) { | 44 const std::string& str) { |
| 44 std::string header = str.substr(0, message_start); | 45 std::string header = str.substr(0, message_start); |
| 45 std::string message = str.substr(message_start); | 46 std::string message = str.substr(message_start); |
| 46 | 47 |
| 47 g_thread_safe_sender.Get()->Send(new GpuHostMsg_OnLogMessage( | 48 g_thread_safe_sender.Get()->Send( |
| 48 severity, header, message)); | 49 new GpuBrowserHostMsg_OnLogMessage(severity, header, message)); |
| 49 | 50 |
| 50 return false; | 51 return false; |
| 51 } | 52 } |
| 52 | 53 |
| 53 // Message filter used to to handle GpuMsg_CreateGpuMemoryBuffer messages on | 54 // Message filter used to to handle GpuBrowserMsg_CreateGpuMemoryBuffer messages |
| 55 // on |
| 54 // the IO thread. This allows the UI thread in the browser process to remain | 56 // the IO thread. This allows the UI thread in the browser process to remain |
| 55 // fast at all times. | 57 // fast at all times. |
| 56 class GpuMemoryBufferMessageFilter : public IPC::MessageFilter { | 58 class GpuMemoryBufferMessageFilter : public IPC::MessageFilter { |
| 57 public: | 59 public: |
| 58 explicit GpuMemoryBufferMessageFilter( | 60 explicit GpuMemoryBufferMessageFilter( |
| 59 GpuMemoryBufferFactory* gpu_memory_buffer_factory) | 61 GpuMemoryBufferFactory* gpu_memory_buffer_factory) |
| 60 : gpu_memory_buffer_factory_(gpu_memory_buffer_factory), | 62 : gpu_memory_buffer_factory_(gpu_memory_buffer_factory), |
| 61 sender_(nullptr) {} | 63 sender_(nullptr) {} |
| 62 | 64 |
| 63 // Overridden from IPC::MessageFilter: | 65 // Overridden from IPC::MessageFilter: |
| 64 void OnFilterAdded(IPC::Sender* sender) override { | 66 void OnFilterAdded(IPC::Sender* sender) override { |
| 65 DCHECK(!sender_); | 67 DCHECK(!sender_); |
| 66 sender_ = sender; | 68 sender_ = sender; |
| 67 } | 69 } |
| 68 void OnFilterRemoved() override { | 70 void OnFilterRemoved() override { |
| 69 DCHECK(sender_); | 71 DCHECK(sender_); |
| 70 sender_ = nullptr; | 72 sender_ = nullptr; |
| 71 } | 73 } |
| 72 bool OnMessageReceived(const IPC::Message& message) override { | 74 bool OnMessageReceived(const IPC::Message& message) override { |
| 73 DCHECK(sender_); | 75 DCHECK(sender_); |
| 74 bool handled = true; | 76 bool handled = true; |
| 75 IPC_BEGIN_MESSAGE_MAP(GpuMemoryBufferMessageFilter, message) | 77 IPC_BEGIN_MESSAGE_MAP(GpuMemoryBufferMessageFilter, message) |
| 76 IPC_MESSAGE_HANDLER(GpuMsg_CreateGpuMemoryBuffer, OnCreateGpuMemoryBuffer) | 78 IPC_MESSAGE_HANDLER(GpuBrowserMsg_CreateGpuMemoryBuffer, |
| 77 IPC_MESSAGE_HANDLER(GpuMsg_CreateGpuMemoryBufferFromHandle, | 79 OnCreateGpuMemoryBuffer) |
| 78 OnCreateGpuMemoryBufferFromHandle) | 80 IPC_MESSAGE_HANDLER(GpuBrowserMsg_CreateGpuMemoryBufferFromHandle, |
| 79 IPC_MESSAGE_UNHANDLED(handled = false) | 81 OnCreateGpuMemoryBufferFromHandle) |
| 82 IPC_MESSAGE_UNHANDLED(handled = false) |
| 80 IPC_END_MESSAGE_MAP() | 83 IPC_END_MESSAGE_MAP() |
| 81 return handled; | 84 return handled; |
| 82 } | 85 } |
| 83 | 86 |
| 84 protected: | 87 protected: |
| 85 ~GpuMemoryBufferMessageFilter() override {} | 88 ~GpuMemoryBufferMessageFilter() override {} |
| 86 | 89 |
| 87 void OnCreateGpuMemoryBuffer( | 90 void OnCreateGpuMemoryBuffer( |
| 88 const GpuMsg_CreateGpuMemoryBuffer_Params& params) { | 91 const GpuBrowserMsg_CreateGpuMemoryBuffer_Params& params) { |
| 89 TRACE_EVENT2("gpu", "GpuMemoryBufferMessageFilter::OnCreateGpuMemoryBuffer", | 92 TRACE_EVENT2("gpu", "GpuMemoryBufferMessageFilter::OnCreateGpuMemoryBuffer", |
| 90 "id", params.id.id, "client_id", params.client_id); | 93 "id", params.id.id, "client_id", params.client_id); |
| 91 | 94 |
| 92 DCHECK(gpu_memory_buffer_factory_); | 95 DCHECK(gpu_memory_buffer_factory_); |
| 93 sender_->Send(new GpuHostMsg_GpuMemoryBufferCreated( | 96 sender_->Send(new GpuBrowserHostMsg_GpuMemoryBufferCreated( |
| 94 gpu_memory_buffer_factory_->CreateGpuMemoryBuffer( | 97 gpu_memory_buffer_factory_->CreateGpuMemoryBuffer( |
| 95 params.id, params.size, params.format, params.usage, | 98 params.id, params.size, params.format, params.usage, |
| 96 params.client_id, params.surface_handle))); | 99 params.client_id, params.surface_handle))); |
| 97 } | 100 } |
| 98 | 101 |
| 99 void OnCreateGpuMemoryBufferFromHandle( | 102 void OnCreateGpuMemoryBufferFromHandle( |
| 100 const GpuMsg_CreateGpuMemoryBufferFromHandle_Params& params) { | 103 const GpuBrowserMsg_CreateGpuMemoryBufferFromHandle_Params& params) { |
| 101 TRACE_EVENT2( | 104 TRACE_EVENT2( |
| 102 "gpu", | 105 "gpu", |
| 103 "GpuMemoryBufferMessageFilter::OnCreateGpuMemoryBufferFromHandle", "id", | 106 "GpuMemoryBufferMessageFilter::OnCreateGpuMemoryBufferFromHandle", "id", |
| 104 params.id.id, "client_id", params.client_id); | 107 params.id.id, "client_id", params.client_id); |
| 105 sender_->Send(new GpuHostMsg_GpuMemoryBufferCreated( | 108 sender_->Send(new GpuBrowserHostMsg_GpuMemoryBufferCreated( |
| 106 gpu_memory_buffer_factory_->CreateGpuMemoryBufferFromHandle( | 109 gpu_memory_buffer_factory_->CreateGpuMemoryBufferFromHandle( |
| 107 params.handle, params.id, params.size, params.format, | 110 params.handle, params.id, params.size, params.format, |
| 108 params.client_id))); | 111 params.client_id))); |
| 109 } | 112 } |
| 110 | 113 |
| 111 GpuMemoryBufferFactory* const gpu_memory_buffer_factory_; | 114 GpuMemoryBufferFactory* const gpu_memory_buffer_factory_; |
| 112 IPC::Sender* sender_; | 115 IPC::Sender* sender_; |
| 113 }; | 116 }; |
| 114 | 117 |
| 115 ChildThreadImpl::Options GetOptions( | 118 ChildThreadImpl::Options GetOptions( |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 // The GPU process must never send a synchronous IPC message to the browser | 214 // The GPU process must never send a synchronous IPC message to the browser |
| 212 // process. This could result in deadlock. | 215 // process. This could result in deadlock. |
| 213 DCHECK(!msg->is_sync()); | 216 DCHECK(!msg->is_sync()); |
| 214 | 217 |
| 215 return ChildThreadImpl::Send(msg); | 218 return ChildThreadImpl::Send(msg); |
| 216 } | 219 } |
| 217 | 220 |
| 218 bool GpuChildThread::OnControlMessageReceived(const IPC::Message& msg) { | 221 bool GpuChildThread::OnControlMessageReceived(const IPC::Message& msg) { |
| 219 bool handled = true; | 222 bool handled = true; |
| 220 IPC_BEGIN_MESSAGE_MAP(GpuChildThread, msg) | 223 IPC_BEGIN_MESSAGE_MAP(GpuChildThread, msg) |
| 221 IPC_MESSAGE_HANDLER(GpuMsg_Initialize, OnInitialize) | 224 IPC_MESSAGE_HANDLER(GpuBrowserMsg_Initialize, OnInitialize) |
| 222 IPC_MESSAGE_HANDLER(GpuMsg_Finalize, OnFinalize) | 225 IPC_MESSAGE_HANDLER(GpuBrowserMsg_Finalize, OnFinalize) |
| 223 IPC_MESSAGE_HANDLER(GpuMsg_CollectGraphicsInfo, OnCollectGraphicsInfo) | 226 IPC_MESSAGE_HANDLER(GpuBrowserMsg_CollectGraphicsInfo, |
| 224 IPC_MESSAGE_HANDLER(GpuMsg_GetVideoMemoryUsageStats, | 227 OnCollectGraphicsInfo) |
| 228 IPC_MESSAGE_HANDLER(GpuBrowserMsg_GetVideoMemoryUsageStats, |
| 225 OnGetVideoMemoryUsageStats) | 229 OnGetVideoMemoryUsageStats) |
| 226 IPC_MESSAGE_HANDLER(GpuMsg_Clean, OnClean) | 230 IPC_MESSAGE_HANDLER(GpuBrowserMsg_Clean, OnClean) |
| 227 IPC_MESSAGE_HANDLER(GpuMsg_Crash, OnCrash) | 231 IPC_MESSAGE_HANDLER(GpuBrowserMsg_Crash, OnCrash) |
| 228 IPC_MESSAGE_HANDLER(GpuMsg_Hang, OnHang) | 232 IPC_MESSAGE_HANDLER(GpuBrowserMsg_Hang, OnHang) |
| 229 IPC_MESSAGE_HANDLER(GpuMsg_DisableWatchdog, OnDisableWatchdog) | 233 IPC_MESSAGE_HANDLER(GpuBrowserMsg_DisableWatchdog, OnDisableWatchdog) |
| 230 IPC_MESSAGE_HANDLER(GpuMsg_GpuSwitched, OnGpuSwitched) | 234 IPC_MESSAGE_HANDLER(GpuBrowserMsg_GpuSwitched, OnGpuSwitched) |
| 231 IPC_MESSAGE_UNHANDLED(handled = false) | 235 IPC_MESSAGE_UNHANDLED(handled = false) |
| 232 IPC_END_MESSAGE_MAP() | 236 IPC_END_MESSAGE_MAP() |
| 233 | 237 |
| 234 if (handled) | 238 if (handled) |
| 235 return true; | 239 return true; |
| 236 | 240 |
| 237 #if defined(USE_OZONE) | 241 #if defined(USE_OZONE) |
| 238 if (ui::OzonePlatform::GetInstance() | 242 if (ui::OzonePlatform::GetInstance() |
| 239 ->GetGpuPlatformSupport() | 243 ->GetGpuPlatformSupport() |
| 240 ->OnMessageReceived(msg)) | 244 ->OnMessageReceived(msg)) |
| 241 return true; | 245 return true; |
| 242 #endif | 246 #endif |
| 243 | 247 |
| 244 return false; | 248 return false; |
| 245 } | 249 } |
| 246 | 250 |
| 247 bool GpuChildThread::OnMessageReceived(const IPC::Message& msg) { | 251 bool GpuChildThread::OnMessageReceived(const IPC::Message& msg) { |
| 248 if (ChildThreadImpl::OnMessageReceived(msg)) | 252 if (ChildThreadImpl::OnMessageReceived(msg)) |
| 249 return true; | 253 return true; |
| 250 | 254 |
| 255 bool handled = true; |
| 256 IPC_BEGIN_MESSAGE_MAP(GpuChildThread, msg) |
| 257 IPC_MESSAGE_HANDLER(GpuBrowserMsg_EstablishChannel, OnEstablishChannel) |
| 258 IPC_MESSAGE_HANDLER(GpuBrowserMsg_CloseChannel, OnCloseChannel) |
| 259 IPC_MESSAGE_HANDLER(GpuBrowserMsg_DestroyGpuMemoryBuffer, |
| 260 OnDestroyGpuMemoryBuffer) |
| 261 IPC_MESSAGE_HANDLER(GpuBrowserMsg_LoadedShader, OnLoadedShader) |
| 262 IPC_MESSAGE_HANDLER(GpuBrowserMsg_UpdateValueState, OnUpdateValueState) |
| 263 #if defined(OS_ANDROID) |
| 264 IPC_MESSAGE_HANDLER(GpuBrowserMsg_WakeUpGpu, OnWakeUpGpu); |
| 265 #endif |
| 266 IPC_MESSAGE_UNHANDLED(handled = false) |
| 267 IPC_END_MESSAGE_MAP() |
| 268 if (handled) |
| 269 return true; |
| 270 |
| 251 return gpu_channel_manager_.get() && | 271 return gpu_channel_manager_.get() && |
| 252 gpu_channel_manager_->OnMessageReceived(msg); | 272 gpu_channel_manager_->OnMessageReceived(msg); |
| 253 } | 273 } |
| 254 | 274 |
| 275 void GpuChildThread::AddSubscription(int32_t client_id, unsigned int target) { |
| 276 Send(new GpuBrowserHostMsg_AddSubscription(client_id, target)); |
| 277 } |
| 278 |
| 279 void GpuChildThread::CacheShader(int32_t client_id, |
| 280 const std::string& key, |
| 281 const std::string& shader) { |
| 282 Send(new GpuBrowserHostMsg_CacheShader(client_id, key, shader)); |
| 283 } |
| 284 |
| 285 void GpuChildThread::ChannelEstablished( |
| 286 const IPC::ChannelHandle& channel_handle) { |
| 287 Send(new GpuBrowserHostMsg_ChannelEstablished(channel_handle)); |
| 288 } |
| 289 |
| 290 void GpuChildThread::DestroyChannel(int client_id) { |
| 291 Send(new GpuBrowserHostMsg_DestroyChannel(client_id)); |
| 292 } |
| 293 |
| 294 void GpuChildThread::DidCreateOffscreenContext(const GURL& active_url) { |
| 295 Send(new GpuBrowserHostMsg_DidCreateOffscreenContext(active_url)); |
| 296 } |
| 297 |
| 298 void GpuChildThread::DidDestroyOffscreenContext(const GURL& active_url) { |
| 299 Send(new GpuBrowserHostMsg_DidDestroyOffscreenContext(active_url)); |
| 300 } |
| 301 |
| 302 void GpuChildThread::DidLoseContext(bool offscreen, |
| 303 gpu::error::ContextLostReason reason, |
| 304 const GURL& active_url) { |
| 305 Send(new GpuBrowserHostMsg_DidLoseContext(offscreen, reason, active_url)); |
| 306 } |
| 307 |
| 308 void GpuChildThread::GpuMemoryUmaStats(const GPUMemoryUmaStats& params) { |
| 309 Send(new GpuBrowserHostMsg_GpuMemoryUmaStats(params)); |
| 310 } |
| 311 |
| 312 void GpuChildThread::RemoveSubscription(int32_t client_id, |
| 313 unsigned int target) { |
| 314 Send(new GpuBrowserHostMsg_RemoveSubscription(client_id, target)); |
| 315 } |
| 316 |
| 255 void GpuChildThread::OnInitialize() { | 317 void GpuChildThread::OnInitialize() { |
| 256 // Record initialization only after collecting the GPU info because that can | 318 // Record initialization only after collecting the GPU info because that can |
| 257 // take a significant amount of time. | 319 // take a significant amount of time. |
| 258 gpu_info_.initialization_time = base::Time::Now() - process_start_time_; | 320 gpu_info_.initialization_time = base::Time::Now() - process_start_time_; |
| 259 Send(new GpuHostMsg_Initialized(!dead_on_arrival_, gpu_info_)); | 321 Send(new GpuBrowserHostMsg_Initialized(!dead_on_arrival_, gpu_info_)); |
| 260 while (!deferred_messages_.empty()) { | 322 while (!deferred_messages_.empty()) { |
| 261 Send(deferred_messages_.front()); | 323 Send(deferred_messages_.front()); |
| 262 deferred_messages_.pop(); | 324 deferred_messages_.pop(); |
| 263 } | 325 } |
| 264 | 326 |
| 265 if (dead_on_arrival_) { | 327 if (dead_on_arrival_) { |
| 266 LOG(ERROR) << "Exiting GPU process due to errors during initialization"; | 328 LOG(ERROR) << "Exiting GPU process due to errors during initialization"; |
| 267 base::MessageLoop::current()->QuitWhenIdle(); | 329 base::MessageLoop::current()->QuitWhenIdle(); |
| 268 return; | 330 return; |
| 269 } | 331 } |
| 270 | 332 |
| 271 // We don't need to pipe log messages if we are running the GPU thread in | 333 // We don't need to pipe log messages if we are running the GPU thread in |
| 272 // the browser process. | 334 // the browser process. |
| 273 if (!in_browser_process_) | 335 if (!in_browser_process_) |
| 274 logging::SetLogMessageHandler(GpuProcessLogMessageHandler); | 336 logging::SetLogMessageHandler(GpuProcessLogMessageHandler); |
| 275 | 337 |
| 276 // Defer creation of the render thread. This is to prevent it from handling | 338 // Defer creation of the render thread. This is to prevent it from handling |
| 277 // IPC messages before the sandbox has been enabled and all other necessary | 339 // IPC messages before the sandbox has been enabled and all other necessary |
| 278 // initialization has succeeded. | 340 // initialization has succeeded. |
| 279 gpu_channel_manager_.reset( | 341 gpu_channel_manager_.reset( |
| 280 new GpuChannelManager(channel(), watchdog_thread_.get(), | 342 new GpuChannelManager(this, channel(), watchdog_thread_.get(), |
| 281 base::ThreadTaskRunnerHandle::Get().get(), | 343 base::ThreadTaskRunnerHandle::Get().get(), |
| 282 ChildProcess::current()->io_task_runner(), | 344 ChildProcess::current()->io_task_runner(), |
| 283 ChildProcess::current()->GetShutDownEvent(), | 345 ChildProcess::current()->GetShutDownEvent(), |
| 284 sync_point_manager_, gpu_memory_buffer_factory_)); | 346 sync_point_manager_, gpu_memory_buffer_factory_)); |
| 285 | 347 |
| 286 #if defined(USE_OZONE) | 348 #if defined(USE_OZONE) |
| 287 ui::OzonePlatform::GetInstance() | 349 ui::OzonePlatform::GetInstance() |
| 288 ->GetGpuPlatformSupport() | 350 ->GetGpuPlatformSupport() |
| 289 ->OnChannelEstablished(this); | 351 ->OnChannelEstablished(this); |
| 290 #endif | 352 #endif |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 GetContentClient()->SetGpuInfo(gpu_info_); | 391 GetContentClient()->SetGpuInfo(gpu_info_); |
| 330 | 392 |
| 331 #if defined(OS_WIN) | 393 #if defined(OS_WIN) |
| 332 // This is slow, but it's the only thing the unsandboxed GPU process does, | 394 // This is slow, but it's the only thing the unsandboxed GPU process does, |
| 333 // and GpuDataManager prevents us from sending multiple collecting requests, | 395 // and GpuDataManager prevents us from sending multiple collecting requests, |
| 334 // so it's OK to be blocking. | 396 // so it's OK to be blocking. |
| 335 gpu::GetDxDiagnostics(&gpu_info_.dx_diagnostics); | 397 gpu::GetDxDiagnostics(&gpu_info_.dx_diagnostics); |
| 336 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoSuccess; | 398 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoSuccess; |
| 337 #endif // OS_WIN | 399 #endif // OS_WIN |
| 338 | 400 |
| 339 Send(new GpuHostMsg_GraphicsInfoCollected(gpu_info_)); | 401 Send(new GpuBrowserHostMsg_GraphicsInfoCollected(gpu_info_)); |
| 340 | 402 |
| 341 #if defined(OS_WIN) | 403 #if defined(OS_WIN) |
| 342 if (!in_browser_process_) { | 404 if (!in_browser_process_) { |
| 343 // The unsandboxed GPU process fulfilled its duty. Rest in peace. | 405 // The unsandboxed GPU process fulfilled its duty. Rest in peace. |
| 344 base::MessageLoop::current()->QuitWhenIdle(); | 406 base::MessageLoop::current()->QuitWhenIdle(); |
| 345 } | 407 } |
| 346 #endif // OS_WIN | 408 #endif // OS_WIN |
| 347 } | 409 } |
| 348 | 410 |
| 349 void GpuChildThread::OnGetVideoMemoryUsageStats() { | 411 void GpuChildThread::OnGetVideoMemoryUsageStats() { |
| 350 GPUVideoMemoryUsageStats video_memory_usage_stats; | 412 GPUVideoMemoryUsageStats video_memory_usage_stats; |
| 351 if (gpu_channel_manager_) | 413 if (gpu_channel_manager_) |
| 352 gpu_channel_manager_->gpu_memory_manager()->GetVideoMemoryUsageStats( | 414 gpu_channel_manager_->gpu_memory_manager()->GetVideoMemoryUsageStats( |
| 353 &video_memory_usage_stats); | 415 &video_memory_usage_stats); |
| 354 Send(new GpuHostMsg_VideoMemoryUsageStats(video_memory_usage_stats)); | 416 Send(new GpuBrowserHostMsg_VideoMemoryUsageStats(video_memory_usage_stats)); |
| 355 } | 417 } |
| 356 | 418 |
| 357 void GpuChildThread::OnClean() { | 419 void GpuChildThread::OnClean() { |
| 358 DVLOG(1) << "GPU: Removing all contexts"; | 420 DVLOG(1) << "GPU: Removing all contexts"; |
| 359 if (gpu_channel_manager_) | 421 if (gpu_channel_manager_) |
| 360 gpu_channel_manager_->LoseAllContexts(); | 422 gpu_channel_manager_->ClearAllChannels(); |
| 361 } | 423 } |
| 362 | 424 |
| 363 void GpuChildThread::OnCrash() { | 425 void GpuChildThread::OnCrash() { |
| 364 DVLOG(1) << "GPU: Simulating GPU crash"; | 426 DVLOG(1) << "GPU: Simulating GPU crash"; |
| 365 // Good bye, cruel world. | 427 // Good bye, cruel world. |
| 366 volatile int* it_s_the_end_of_the_world_as_we_know_it = NULL; | 428 volatile int* it_s_the_end_of_the_world_as_we_know_it = NULL; |
| 367 *it_s_the_end_of_the_world_as_we_know_it = 0xdead; | 429 *it_s_the_end_of_the_world_as_we_know_it = 0xdead; |
| 368 } | 430 } |
| 369 | 431 |
| 370 void GpuChildThread::OnHang() { | 432 void GpuChildThread::OnHang() { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 386 watchdog_thread_->Stop(); | 448 watchdog_thread_->Stop(); |
| 387 } | 449 } |
| 388 } | 450 } |
| 389 | 451 |
| 390 void GpuChildThread::OnGpuSwitched() { | 452 void GpuChildThread::OnGpuSwitched() { |
| 391 DVLOG(1) << "GPU: GPU has switched"; | 453 DVLOG(1) << "GPU: GPU has switched"; |
| 392 // Notify observers in the GPU process. | 454 // Notify observers in the GPU process. |
| 393 ui::GpuSwitchingManager::GetInstance()->NotifyGpuSwitched(); | 455 ui::GpuSwitchingManager::GetInstance()->NotifyGpuSwitched(); |
| 394 } | 456 } |
| 395 | 457 |
| 458 void GpuChildThread::OnEstablishChannel(const EstablishChannelParams& params) { |
| 459 if (gpu_channel_manager_) |
| 460 gpu_channel_manager_->EstablishChannel(params); |
| 461 } |
| 462 |
| 463 void GpuChildThread::OnCloseChannel(const IPC::ChannelHandle& channel_handle) { |
| 464 if (gpu_channel_manager_) |
| 465 gpu_channel_manager_->CloseChannel(channel_handle); |
| 466 } |
| 467 |
| 468 void GpuChildThread::OnLoadedShader(const std::string& shader) { |
| 469 if (gpu_channel_manager_) |
| 470 gpu_channel_manager_->LoadedShader(shader); |
| 471 } |
| 472 |
| 473 void GpuChildThread::OnDestroyGpuMemoryBuffer( |
| 474 gfx::GpuMemoryBufferId id, |
| 475 int client_id, |
| 476 const gpu::SyncToken& sync_token) { |
| 477 if (gpu_channel_manager_) |
| 478 gpu_channel_manager_->DestroyGpuMemoryBuffer(id, client_id, sync_token); |
| 479 } |
| 480 |
| 481 void GpuChildThread::OnUpdateValueState(int client_id, |
| 482 unsigned int target, |
| 483 const gpu::ValueState& state) { |
| 484 if (gpu_channel_manager_) |
| 485 gpu_channel_manager_->UpdateValueState(client_id, target, state); |
| 486 } |
| 487 |
| 488 #if defined(OS_ANDROID) |
| 489 void GpuChildThread::OnWakeUpGpu() { |
| 490 if (gpu_channel_manager_) |
| 491 gpu_channel_manager_->WakeUpGpu(); |
| 492 } |
| 493 #endif |
| 494 |
| 495 void GpuChildThread::OnLoseAllContexts() { |
| 496 if (gpu_channel_manager_) |
| 497 gpu_channel_manager_->ClearAllChannels(); |
| 498 } |
| 499 |
| 396 void GpuChildThread::BindProcessControlRequest( | 500 void GpuChildThread::BindProcessControlRequest( |
| 397 mojo::InterfaceRequest<ProcessControl> request) { | 501 mojo::InterfaceRequest<ProcessControl> request) { |
| 398 DVLOG(1) << "GPU: Binding ProcessControl request"; | 502 DVLOG(1) << "GPU: Binding ProcessControl request"; |
| 399 DCHECK(process_control_); | 503 DCHECK(process_control_); |
| 400 process_control_bindings_.AddBinding(process_control_.get(), | 504 process_control_bindings_.AddBinding(process_control_.get(), |
| 401 std::move(request)); | 505 std::move(request)); |
| 402 } | 506 } |
| 403 | 507 |
| 404 } // namespace content | 508 } // namespace content |
| OLD | NEW |