| Index: services/ui/gpu/gpu_service.cc
|
| diff --git a/services/ui/gpu/gpu_service.cc b/services/ui/gpu/gpu_service.cc
|
| index 75a81a656cc896852571152417eac520c40b91e7..948353c70e5ef2cbb6a08bc8bb97f43637bb832a 100644
|
| --- a/services/ui/gpu/gpu_service.cc
|
| +++ b/services/ui/gpu/gpu_service.cc
|
| @@ -6,6 +6,7 @@
|
|
|
| #include "base/bind.h"
|
| #include "base/debug/crash_logging.h"
|
| +#include "base/lazy_instance.h"
|
| #include "base/memory/shared_memory.h"
|
| #include "base/threading/thread_task_runner_handle.h"
|
| #include "build/build_config.h"
|
| @@ -42,6 +43,23 @@
|
|
|
| namespace ui {
|
|
|
| +namespace {
|
| +
|
| +static base::LazyInstance<base::Callback<
|
| + void(int severity, size_t message_start, const std::string& message)>>::
|
| + Leaky g_log_callback = LAZY_INSTANCE_INITIALIZER;
|
| +
|
| +bool GpuLogMessageHandler(int severity,
|
| + const char* file,
|
| + int line,
|
| + size_t message_start,
|
| + const std::string& message) {
|
| + g_log_callback.Get().Run(severity, message_start, message);
|
| + return false;
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| GpuService::GpuService(const gpu::GPUInfo& gpu_info,
|
| std::unique_ptr<gpu::GpuWatchdogThread> watchdog_thread,
|
| gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory,
|
| @@ -57,6 +75,9 @@ GpuService::GpuService(const gpu::GPUInfo& gpu_info,
|
| sync_point_manager_(nullptr) {}
|
|
|
| GpuService::~GpuService() {
|
| + logging::SetLogMessageHandler(nullptr);
|
| + g_log_callback.Get() =
|
| + base::Callback<void(int, size_t, const std::string&)>();
|
| bindings_.CloseAllBindings();
|
| media_gpu_channel_manager_.reset();
|
| gpu_channel_manager_.reset();
|
| @@ -87,6 +108,15 @@ void GpuService::InitializeWithHost(mojom::GpuHostPtr gpu_host,
|
| gpu_host->DidInitialize(gpu_info_);
|
| gpu_host_ =
|
| mojom::ThreadSafeGpuHostPtr::Create(gpu_host.PassInterface(), io_runner_);
|
| + if (!in_host_process_) {
|
| + // The global callback is reset from the dtor. So Unretained() here is safe.
|
| + // Note that the callback can be called from any thread. Consequently, the
|
| + // callback cannot use a WeakPtr.
|
| + g_log_callback.Get() =
|
| + base::Bind(&GpuService::RecordLogMessage, base::Unretained(this));
|
| + logging::SetLogMessageHandler(GpuLogMessageHandler);
|
| + }
|
| +
|
| sync_point_manager_ = sync_point_manager;
|
| if (!sync_point_manager_) {
|
| owned_sync_point_manager_ = base::MakeUnique<gpu::SyncPointManager>();
|
| @@ -111,6 +141,14 @@ void GpuService::Bind(mojom::GpuServiceRequest request) {
|
| bindings_.AddBinding(this, std::move(request));
|
| }
|
|
|
| +void GpuService::RecordLogMessage(int severity,
|
| + size_t message_start,
|
| + const std::string& str) {
|
| + std::string header = str.substr(0, message_start);
|
| + std::string message = str.substr(message_start);
|
| + (*gpu_host_)->RecordLogMessage(severity, header, message);
|
| +}
|
| +
|
| void GpuService::CreateGpuMemoryBuffer(
|
| gfx::GpuMemoryBufferId id,
|
| const gfx::Size& size,
|
|
|