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

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.cc » ('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 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(
« no previous file with comments | « services/ui/public/cpp/gpu_service.h ('k') | ui/views/mus/window_manager_connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698