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

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
« no previous file with comments | « services/ui/public/cpp/gpu_service.h ('k') | ui/views/mus/window_manager_connection.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 a9c9b4d2b0b2cba4202a277cfb8b5a124a86b110..2ba9dfcb868dd9863b415b84bac2b1f256d6fe6b 100644
--- a/services/ui/public/cpp/gpu_service.cc
+++ b/services/ui/public/cpp/gpu_service.cc
@@ -30,20 +30,25 @@ void PostTask(scoped_refptr<base::SingleThreadTaskRunner> runner,
} // namespace
-GpuService::GpuService(shell::Connector* connector)
+GpuService::GpuService(shell::Connector* connector,
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner)
: main_task_runner_(base::ThreadTaskRunnerHandle::Get()),
+ io_task_runner_(std::move(task_runner)),
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));
+ 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();
+ }
}
GpuService::~GpuService() {
@@ -53,9 +58,10 @@ GpuService::~GpuService() {
}
// static
-std::unique_ptr<GpuService> GpuService::Initialize(
- shell::Connector* connector) {
- return base::WrapUnique(new GpuService(connector));
+std::unique_ptr<GpuService> GpuService::Create(
+ shell::Connector* connector,
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
+ return base::WrapUnique(new GpuService(connector, std::move(task_runner)));
}
void GpuService::EstablishGpuChannel(
@@ -205,7 +211,7 @@ bool GpuService::IsMainThread() {
scoped_refptr<base::SingleThreadTaskRunner>
GpuService::GetIOThreadTaskRunner() {
- return io_thread_.task_runner();
+ return io_task_runner_;
}
std::unique_ptr<base::SharedMemory> GpuService::AllocateSharedMemory(
« no previous file with comments | « services/ui/public/cpp/gpu_service.h ('k') | ui/views/mus/window_manager_connection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698