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