Chromium Code Reviews| Index: services/ui/public/cpp/gpu_service.cc |
| diff --git a/services/ui/public/cpp/gpu_service.cc b/services/ui/public/cpp/gpu_service.cc |
| index 6c70440f940189eca61194151bf4c52152597284..5adeb60423ff7dcf878bc21b15dcc976ca201ac2 100644 |
| --- a/services/ui/public/cpp/gpu_service.cc |
| +++ b/services/ui/public/cpp/gpu_service.cc |
| @@ -35,15 +35,11 @@ GpuService::GpuService(shell::Connector* connector) |
| connector_(connector), |
| shutdown_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| base::WaitableEvent::InitialState::NOT_SIGNALED), |
| - io_thread_("GPUIOThread"), |
| gpu_memory_buffer_manager_(new MojoGpuMemoryBufferManager), |
| is_establishing_(false), |
| establishing_condition_(&lock_) { |
| DCHECK(main_task_runner_); |
| DCHECK(connector_); |
| - base::Thread::Options thread_options(base::MessageLoop::TYPE_IO, 0); |
| - thread_options.priority = base::ThreadPriority::NORMAL; |
| - CHECK(io_thread_.StartWithOptions(thread_options)); |
| } |
| GpuService::~GpuService() { |
| @@ -53,11 +49,19 @@ GpuService::~GpuService() { |
| } |
| // static |
| -std::unique_ptr<GpuService> GpuService::Initialize( |
| +std::unique_ptr<GpuService> GpuService::Create( |
| shell::Connector* connector) { |
| return base::WrapUnique(new GpuService(connector)); |
| } |
| +void GpuService::SetIOThreadTaskRunner( |
| + scoped_refptr<base::SingleThreadTaskRunner> io_task_runner) { |
| + DCHECK(!io_task_runner_) |
|
piman
2016/08/22 19:42:03
Would it make sense instead to pass the task runne
sadrul
2016/08/22 20:05:54
Ah, interesting. Yes, Fady brought up the issue ea
piman
2016/08/22 20:31:50
I feel like plumbing the task runner through Windo
sadrul
2016/08/22 21:20:38
Agreed. And contrary to popular meme, obviously co
|
| + << "The task runner cannot be changed once set."; |
| + DCHECK(io_task_runner); |
| + io_task_runner_ = std::move(io_task_runner); |
| +} |
| + |
| void GpuService::EstablishGpuChannel( |
| const gpu::GpuChannelEstablishedCallback& callback) { |
| base::AutoLock auto_lock(lock_); |
| @@ -205,7 +209,14 @@ bool GpuService::IsMainThread() { |
| scoped_refptr<base::SingleThreadTaskRunner> |
| GpuService::GetIOThreadTaskRunner() { |
| - return io_thread_.task_runner(); |
| + if (!io_task_runner_) { |
| + io_thread_.reset(new base::Thread("GPUIOThread")); |
| + base::Thread::Options thread_options(base::MessageLoop::TYPE_IO, 0); |
| + thread_options.priority = base::ThreadPriority::NORMAL; |
| + CHECK(io_thread_->StartWithOptions(thread_options)); |
| + io_task_runner_ = io_thread_->task_runner(); |
| + } |
| + return io_task_runner_; |
| } |
| std::unique_ptr<base::SharedMemory> GpuService::AllocateSharedMemory( |