| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "services/ui/gpu/gpu_service.h" | 5 #include "services/ui/gpu/gpu_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/crash_logging.h" | 8 #include "base/debug/crash_logging.h" |
| 9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #include "media/gpu/ipc/service/media_gpu_channel_manager.h" | 30 #include "media/gpu/ipc/service/media_gpu_channel_manager.h" |
| 31 #include "mojo/public/cpp/bindings/strong_binding.h" | 31 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 32 #include "ui/gl/gl_implementation.h" | 32 #include "ui/gl/gl_implementation.h" |
| 33 #include "ui/gl/gl_switches.h" | 33 #include "ui/gl/gl_switches.h" |
| 34 #include "ui/gl/gpu_switching_manager.h" | 34 #include "ui/gl/gpu_switching_manager.h" |
| 35 #include "ui/gl/init/gl_factory.h" | 35 #include "ui/gl/init/gl_factory.h" |
| 36 #include "url/gurl.h" | 36 #include "url/gurl.h" |
| 37 | 37 |
| 38 namespace ui { | 38 namespace ui { |
| 39 | 39 |
| 40 // static |
| 41 const char GpuService::kActiveUrlCrashKey[] = "url-chunk"; |
| 42 |
| 40 GpuService::GpuService(const gpu::GPUInfo& gpu_info, | 43 GpuService::GpuService(const gpu::GPUInfo& gpu_info, |
| 41 std::unique_ptr<gpu::GpuWatchdogThread> watchdog_thread, | 44 std::unique_ptr<gpu::GpuWatchdogThread> watchdog_thread, |
| 42 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory, | 45 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory, |
| 43 scoped_refptr<base::SingleThreadTaskRunner> io_runner) | 46 scoped_refptr<base::SingleThreadTaskRunner> io_runner) |
| 44 : io_runner_(std::move(io_runner)), | 47 : io_runner_(std::move(io_runner)), |
| 45 shutdown_event_(base::WaitableEvent::ResetPolicy::MANUAL, | 48 shutdown_event_(base::WaitableEvent::ResetPolicy::MANUAL, |
| 46 base::WaitableEvent::InitialState::NOT_SIGNALED), | 49 base::WaitableEvent::InitialState::NOT_SIGNALED), |
| 47 watchdog_thread_(std::move(watchdog_thread)), | 50 watchdog_thread_(std::move(watchdog_thread)), |
| 48 gpu_memory_buffer_factory_(gpu_memory_buffer_factory), | 51 gpu_memory_buffer_factory_(gpu_memory_buffer_factory), |
| 49 gpu_info_(gpu_info) {} | 52 gpu_info_(gpu_info) {} |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 | 148 |
| 146 #if defined(OS_WIN) | 149 #if defined(OS_WIN) |
| 147 void GpuService::SendAcceleratedSurfaceCreatedChildWindow( | 150 void GpuService::SendAcceleratedSurfaceCreatedChildWindow( |
| 148 gpu::SurfaceHandle parent_window, | 151 gpu::SurfaceHandle parent_window, |
| 149 gpu::SurfaceHandle child_window) { | 152 gpu::SurfaceHandle child_window) { |
| 150 gpu_host_->SetChildSurface(parent_window, child_window); | 153 gpu_host_->SetChildSurface(parent_window, child_window); |
| 151 } | 154 } |
| 152 #endif | 155 #endif |
| 153 | 156 |
| 154 void GpuService::SetActiveURL(const GURL& url) { | 157 void GpuService::SetActiveURL(const GURL& url) { |
| 155 constexpr char kActiveURL[] = "url-chunk"; | 158 base::debug::SetCrashKeyValue(kActiveUrlCrashKey, |
| 156 base::debug::SetCrashKeyValue(kActiveURL, url.possibly_invalid_spec()); | 159 url.possibly_invalid_spec()); |
| 157 } | 160 } |
| 158 | 161 |
| 159 void GpuService::EstablishGpuChannel( | 162 void GpuService::EstablishGpuChannel( |
| 160 int32_t client_id, | 163 int32_t client_id, |
| 161 uint64_t client_tracing_id, | 164 uint64_t client_tracing_id, |
| 162 bool is_gpu_host, | 165 bool is_gpu_host, |
| 163 const EstablishGpuChannelCallback& callback) { | 166 const EstablishGpuChannelCallback& callback) { |
| 164 DCHECK(CalledOnValidThread()); | 167 DCHECK(CalledOnValidThread()); |
| 165 | 168 |
| 166 if (!gpu_channel_manager_) { | 169 if (!gpu_channel_manager_) { |
| 167 callback.Run(mojo::ScopedMessagePipeHandle()); | 170 callback.Run(mojo::ScopedMessagePipeHandle()); |
| 168 return; | 171 return; |
| 169 } | 172 } |
| 170 | 173 |
| 171 const bool preempts = is_gpu_host; | 174 const bool preempts = is_gpu_host; |
| 172 const bool allow_view_command_buffers = is_gpu_host; | 175 const bool allow_view_command_buffers = is_gpu_host; |
| 173 const bool allow_real_time_streams = is_gpu_host; | 176 const bool allow_real_time_streams = is_gpu_host; |
| 174 mojo::ScopedMessagePipeHandle channel_handle; | 177 mojo::ScopedMessagePipeHandle channel_handle; |
| 175 IPC::ChannelHandle handle = gpu_channel_manager_->EstablishChannel( | 178 IPC::ChannelHandle handle = gpu_channel_manager_->EstablishChannel( |
| 176 client_id, client_tracing_id, preempts, allow_view_command_buffers, | 179 client_id, client_tracing_id, preempts, allow_view_command_buffers, |
| 177 allow_real_time_streams); | 180 allow_real_time_streams); |
| 178 channel_handle.reset(handle.mojo_handle); | 181 channel_handle.reset(handle.mojo_handle); |
| 179 media_gpu_channel_manager_->AddChannel(client_id); | 182 media_gpu_channel_manager_->AddChannel(client_id); |
| 180 callback.Run(std::move(channel_handle)); | 183 callback.Run(std::move(channel_handle)); |
| 181 } | 184 } |
| 182 | 185 |
| 183 } // namespace ui | 186 } // namespace ui |
| OLD | NEW |