Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(246)

Unified Diff: services/ui/public/cpp/gpu_service.cc

Issue 2249413004: services/ui: Allow injecting the IO thread task runner for gpu channel. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..71c973f1d9e1d1ea6674e3b721072a7262565bc3 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() {
@@ -58,6 +54,12 @@ std::unique_ptr<GpuService> GpuService::Initialize(
return base::WrapUnique(new GpuService(connector));
}
+void GpuService::SetIOThreadTaskRunner(
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
+ DCHECK(!io_task_runner_);
+ io_task_runner_ = std::move(task_runner);
+}
+
void GpuService::EstablishGpuChannel(
const gpu::GpuChannelEstablishedCallback& callback) {
base::AutoLock auto_lock(lock_);
@@ -205,7 +207,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(
« services/ui/public/cpp/gpu_service.h ('K') | « services/ui/public/cpp/gpu_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698