| Index: services/ui/gpu/gpu_service_internal.cc
|
| diff --git a/services/ui/gpu/gpu_service_internal.cc b/services/ui/gpu/gpu_service_internal.cc
|
| index 75a30333518e0ec1e60aac476d176095c94db086..218d18424603e44dcbe72cc3e21de6cf0aa98782 100644
|
| --- a/services/ui/gpu/gpu_service_internal.cc
|
| +++ b/services/ui/gpu/gpu_service_internal.cc
|
| @@ -28,115 +28,39 @@
|
| #include "ui/gl/init/gl_factory.h"
|
| #include "url/gurl.h"
|
|
|
| -namespace {
|
| -
|
| -#if defined(OS_WIN)
|
| -std::unique_ptr<base::MessagePump> CreateMessagePumpWin() {
|
| - base::MessagePumpForGpu::InitFactory();
|
| - return base::MessageLoop::CreateMessagePumpForType(
|
| - base::MessageLoop::TYPE_UI);
|
| -}
|
| -#endif // defined(OS_WIN)
|
| -
|
| -#if defined(USE_X11)
|
| -std::unique_ptr<base::MessagePump> CreateMessagePumpX11() {
|
| - // TODO(sad): This should create a TYPE_UI message pump, and create a
|
| - // PlatformEventSource when gpu process split happens.
|
| - return base::MessageLoop::CreateMessagePumpForType(
|
| - base::MessageLoop::TYPE_DEFAULT);
|
| -}
|
| -#endif // defined(USE_X11)
|
| -
|
| -#if defined(OS_MACOSX)
|
| -std::unique_ptr<base::MessagePump> CreateMessagePumpMac() {
|
| - return base::MakeUnique<base::MessagePumpCFRunLoop>();
|
| -}
|
| -#endif // defined(OS_MACOSX)
|
| -
|
| -} // namespace
|
| -
|
| namespace ui {
|
|
|
| GpuServiceInternal::GpuServiceInternal(
|
| const gpu::GPUInfo& gpu_info,
|
| gpu::GpuWatchdogThread* watchdog_thread,
|
| - gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory)
|
| - : main_task_runner_(base::ThreadTaskRunnerHandle::Get()),
|
| + gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory,
|
| + scoped_refptr<base::SingleThreadTaskRunner> io_runner)
|
| + : io_runner_(std::move(io_runner)),
|
| shutdown_event_(base::WaitableEvent::ResetPolicy::MANUAL,
|
| base::WaitableEvent::InitialState::NOT_SIGNALED),
|
| - gpu_thread_("GpuThread"),
|
| - io_thread_("GpuIOThread"),
|
| watchdog_thread_(watchdog_thread),
|
| gpu_memory_buffer_factory_(gpu_memory_buffer_factory),
|
| gpu_info_(gpu_info),
|
| - binding_(this) {
|
| - base::Thread::Options thread_options;
|
| -
|
| -#if defined(OS_WIN)
|
| - thread_options.message_pump_factory = base::Bind(&CreateMessagePumpWin);
|
| -#elif defined(USE_X11)
|
| - thread_options.message_pump_factory = base::Bind(&CreateMessagePumpX11);
|
| -#elif defined(OS_LINUX)
|
| - thread_options.message_loop_type = base::MessageLoop::TYPE_DEFAULT;
|
| -#elif defined(OS_MACOSX)
|
| - thread_options.message_pump_factory = base::Bind(&CreateMessagePumpMac);
|
| -#else
|
| - thread_options.message_loop_type = base::MessageLoop::TYPE_IO;
|
| -#endif
|
| -
|
| -#if defined(OS_ANDROID) || defined(OS_CHROMEOS)
|
| - thread_options.priority = base::ThreadPriority::DISPLAY;
|
| -#endif
|
| - CHECK(gpu_thread_.StartWithOptions(thread_options));
|
| -
|
| - // TODO(sad): We do not need the IO thread once gpu has a separate process. It
|
| - // should be possible to use |main_task_runner_| for doing IO tasks.
|
| - thread_options = base::Thread::Options(base::MessageLoop::TYPE_IO, 0);
|
| - thread_options.priority = base::ThreadPriority::NORMAL;
|
| -#if defined(OS_ANDROID) || defined(OS_CHROMEOS)
|
| - // TODO(reveman): Remove this in favor of setting it explicitly for each type
|
| - // of process.
|
| - thread_options.priority = base::ThreadPriority::DISPLAY;
|
| -#endif
|
| - CHECK(io_thread_.StartWithOptions(thread_options));
|
| -}
|
| + binding_(this) {}
|
|
|
| GpuServiceInternal::~GpuServiceInternal() {
|
| - // Tear down the binding in the gpu thread.
|
| - gpu_thread_.task_runner()->PostTask(
|
| - FROM_HERE, base::Bind(&GpuServiceInternal::TearDownGpuThread,
|
| - base::Unretained(this)));
|
| - gpu_thread_.Stop();
|
| + binding_.Close();
|
| + media_service_.reset();
|
| + gpu_channel_manager_.reset();
|
| + owned_sync_point_manager_.reset();
|
|
|
| // Signal this event before destroying the child process. That way all
|
| // background threads can cleanup.
|
| // For example, in the renderer the RenderThread instances will be able to
|
| // notice shutdown before the render process begins waiting for them to exit.
|
| shutdown_event_.Signal();
|
| - io_thread_.Stop();
|
| }
|
|
|
| void GpuServiceInternal::Add(mojom::GpuServiceInternalRequest request) {
|
| - // Unretained() is OK here since the thread/task runner is owned by |this|.
|
| - gpu_thread_.task_runner()->PostTask(
|
| - FROM_HERE,
|
| - base::Bind(&GpuServiceInternal::BindOnGpuThread, base::Unretained(this),
|
| - base::Passed(std::move(request))));
|
| -}
|
| -
|
| -void GpuServiceInternal::BindOnGpuThread(
|
| - mojom::GpuServiceInternalRequest request) {
|
| binding_.Close();
|
| binding_.Bind(std::move(request));
|
| }
|
|
|
| -void GpuServiceInternal::TearDownGpuThread() {
|
| - binding_.Close();
|
| - media_service_.reset();
|
| - gpu_channel_manager_.reset();
|
| - owned_sync_point_manager_.reset();
|
| -}
|
| -
|
| gfx::GpuMemoryBufferHandle GpuServiceInternal::CreateGpuMemoryBuffer(
|
| gfx::GpuMemoryBufferId id,
|
| const gfx::Size& size,
|
| @@ -144,7 +68,7 @@ gfx::GpuMemoryBufferHandle GpuServiceInternal::CreateGpuMemoryBuffer(
|
| gfx::BufferUsage usage,
|
| int client_id,
|
| gpu::SurfaceHandle surface_handle) {
|
| - DCHECK(gpu_thread_.task_runner()->BelongsToCurrentThread());
|
| + DCHECK(CalledOnValidThread());
|
| return gpu_memory_buffer_factory_->CreateGpuMemoryBuffer(
|
| id, size, format, usage, client_id, surface_handle);
|
| }
|
| @@ -153,7 +77,7 @@ void GpuServiceInternal::DestroyGpuMemoryBuffer(
|
| gfx::GpuMemoryBufferId id,
|
| int client_id,
|
| const gpu::SyncToken& sync_token) {
|
| - DCHECK(gpu_thread_.task_runner()->BelongsToCurrentThread());
|
| + DCHECK(CalledOnValidThread());
|
| if (gpu_channel_manager_)
|
| gpu_channel_manager_->DestroyGpuMemoryBuffer(id, client_id, sync_token);
|
| }
|
| @@ -196,7 +120,7 @@ void GpuServiceInternal::SetActiveURL(const GURL& url) {
|
| }
|
|
|
| void GpuServiceInternal::Initialize(const InitializeCallback& callback) {
|
| - DCHECK(gpu_thread_.task_runner()->BelongsToCurrentThread());
|
| + DCHECK(CalledOnValidThread());
|
| gpu_info_.video_decode_accelerator_capabilities =
|
| media::GpuVideoDecodeAccelerator::GetCapabilities(gpu_preferences_);
|
| gpu_info_.video_encode_accelerator_supported_profiles =
|
| @@ -214,7 +138,7 @@ void GpuServiceInternal::Initialize(const InitializeCallback& callback) {
|
| // initialization has succeeded.
|
| gpu_channel_manager_.reset(new gpu::GpuChannelManager(
|
| gpu_preferences_, this, watchdog_thread_,
|
| - base::ThreadTaskRunnerHandle::Get().get(), io_thread_.task_runner().get(),
|
| + base::ThreadTaskRunnerHandle::Get().get(), io_runner_.get(),
|
| &shutdown_event_, owned_sync_point_manager_.get(),
|
| gpu_memory_buffer_factory_));
|
|
|
| @@ -227,7 +151,7 @@ void GpuServiceInternal::EstablishGpuChannel(
|
| uint64_t client_tracing_id,
|
| bool is_gpu_host,
|
| const EstablishGpuChannelCallback& callback) {
|
| - DCHECK(gpu_thread_.task_runner()->BelongsToCurrentThread());
|
| + DCHECK(CalledOnValidThread());
|
|
|
| if (!gpu_channel_manager_) {
|
| callback.Run(mojo::ScopedMessagePipeHandle());
|
|
|