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" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #include "ui/gl/gl_switches.h" | 44 #include "ui/gl/gl_switches.h" |
45 #include "ui/gl/gpu_switching_manager.h" | 45 #include "ui/gl/gpu_switching_manager.h" |
46 #include "ui/gl/init/gl_factory.h" | 46 #include "ui/gl/init/gl_factory.h" |
47 #include "url/gurl.h" | 47 #include "url/gurl.h" |
48 | 48 |
49 #if defined(USE_OZONE) | 49 #if defined(USE_OZONE) |
50 #include "ui/ozone/public/ozone_platform.h" | 50 #include "ui/ozone/public/ozone_platform.h" |
51 #endif | 51 #endif |
52 | 52 |
53 #if defined(OS_ANDROID) | 53 #if defined(OS_ANDROID) |
| 54 #include "base/android/throw_uncaught_exception.h" |
54 #include "media/base/android/media_client_android.h" | 55 #include "media/base/android/media_client_android.h" |
55 #include "media/gpu/avda_codec_allocator.h" | 56 #include "media/gpu/avda_codec_allocator.h" |
56 #endif | 57 #endif |
57 | 58 |
58 namespace content { | 59 namespace content { |
59 namespace { | 60 namespace { |
60 | 61 |
61 static base::LazyInstance<scoped_refptr<ThreadSafeSender> > | 62 static base::LazyInstance<scoped_refptr<ThreadSafeSender> > |
62 g_thread_safe_sender = LAZY_INSTANCE_INITIALIZER; | 63 g_thread_safe_sender = LAZY_INSTANCE_INITIALIZER; |
63 | 64 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 bool GpuChildThread::OnControlMessageReceived(const IPC::Message& msg) { | 246 bool GpuChildThread::OnControlMessageReceived(const IPC::Message& msg) { |
246 bool handled = true; | 247 bool handled = true; |
247 IPC_BEGIN_MESSAGE_MAP(GpuChildThread, msg) | 248 IPC_BEGIN_MESSAGE_MAP(GpuChildThread, msg) |
248 IPC_MESSAGE_HANDLER(GpuMsg_Finalize, OnFinalize) | 249 IPC_MESSAGE_HANDLER(GpuMsg_Finalize, OnFinalize) |
249 IPC_MESSAGE_HANDLER(GpuMsg_CollectGraphicsInfo, OnCollectGraphicsInfo) | 250 IPC_MESSAGE_HANDLER(GpuMsg_CollectGraphicsInfo, OnCollectGraphicsInfo) |
250 IPC_MESSAGE_HANDLER(GpuMsg_GetVideoMemoryUsageStats, | 251 IPC_MESSAGE_HANDLER(GpuMsg_GetVideoMemoryUsageStats, |
251 OnGetVideoMemoryUsageStats) | 252 OnGetVideoMemoryUsageStats) |
252 IPC_MESSAGE_HANDLER(GpuMsg_Clean, OnClean) | 253 IPC_MESSAGE_HANDLER(GpuMsg_Clean, OnClean) |
253 IPC_MESSAGE_HANDLER(GpuMsg_Crash, OnCrash) | 254 IPC_MESSAGE_HANDLER(GpuMsg_Crash, OnCrash) |
254 IPC_MESSAGE_HANDLER(GpuMsg_Hang, OnHang) | 255 IPC_MESSAGE_HANDLER(GpuMsg_Hang, OnHang) |
| 256 #if defined(OS_ANDROID) |
| 257 IPC_MESSAGE_HANDLER(GpuMsg_JavaCrash, OnJavaCrash) |
| 258 #endif |
255 IPC_MESSAGE_HANDLER(GpuMsg_GpuSwitched, OnGpuSwitched) | 259 IPC_MESSAGE_HANDLER(GpuMsg_GpuSwitched, OnGpuSwitched) |
256 IPC_MESSAGE_UNHANDLED(handled = false) | 260 IPC_MESSAGE_UNHANDLED(handled = false) |
257 IPC_END_MESSAGE_MAP() | 261 IPC_END_MESSAGE_MAP() |
258 | 262 |
259 return handled; | 263 return handled; |
260 } | 264 } |
261 | 265 |
262 bool GpuChildThread::OnMessageReceived(const IPC::Message& msg) { | 266 bool GpuChildThread::OnMessageReceived(const IPC::Message& msg) { |
263 if (ChildThreadImpl::OnMessageReceived(msg)) | 267 if (ChildThreadImpl::OnMessageReceived(msg)) |
264 return true; | 268 return true; |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 } | 443 } |
440 | 444 |
441 void GpuChildThread::OnHang() { | 445 void GpuChildThread::OnHang() { |
442 DVLOG(1) << "GPU: Simulating GPU hang"; | 446 DVLOG(1) << "GPU: Simulating GPU hang"; |
443 for (;;) { | 447 for (;;) { |
444 // Do not sleep here. The GPU watchdog timer tracks the amount of user | 448 // Do not sleep here. The GPU watchdog timer tracks the amount of user |
445 // time this thread is using and it doesn't use much while calling Sleep. | 449 // time this thread is using and it doesn't use much while calling Sleep. |
446 } | 450 } |
447 } | 451 } |
448 | 452 |
| 453 #if defined(OS_ANDROID) |
| 454 void GpuChildThread::OnJavaCrash() { |
| 455 base::android::ThrowUncaughtException(); |
| 456 } |
| 457 #endif |
| 458 |
449 void GpuChildThread::OnGpuSwitched() { | 459 void GpuChildThread::OnGpuSwitched() { |
450 DVLOG(1) << "GPU: GPU has switched"; | 460 DVLOG(1) << "GPU: GPU has switched"; |
451 // Notify observers in the GPU process. | 461 // Notify observers in the GPU process. |
452 if (!in_browser_process_) | 462 if (!in_browser_process_) |
453 ui::GpuSwitchingManager::GetInstance()->NotifyGpuSwitched(); | 463 ui::GpuSwitchingManager::GetInstance()->NotifyGpuSwitched(); |
454 } | 464 } |
455 | 465 |
456 void GpuChildThread::OnEstablishChannel(const EstablishChannelParams& params) { | 466 void GpuChildThread::OnEstablishChannel(const EstablishChannelParams& params) { |
457 if (!gpu_channel_manager()) | 467 if (!gpu_channel_manager()) |
458 return; | 468 return; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 | 506 |
497 void GpuChildThread::BindServiceFactoryRequest( | 507 void GpuChildThread::BindServiceFactoryRequest( |
498 service_manager::mojom::ServiceFactoryRequest request) { | 508 service_manager::mojom::ServiceFactoryRequest request) { |
499 DVLOG(1) << "GPU: Binding service_manager::mojom::ServiceFactoryRequest"; | 509 DVLOG(1) << "GPU: Binding service_manager::mojom::ServiceFactoryRequest"; |
500 DCHECK(service_factory_); | 510 DCHECK(service_factory_); |
501 service_factory_bindings_.AddBinding(service_factory_.get(), | 511 service_factory_bindings_.AddBinding(service_factory_.get(), |
502 std::move(request)); | 512 std::move(request)); |
503 } | 513 } |
504 | 514 |
505 } // namespace content | 515 } // namespace content |
OLD | NEW |