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

Unified Diff: services/ui/common/gpu_service.cc

Issue 2197613003: gpu: Introduce GpuChannelEstablishFactory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 5 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
« gpu/ipc/client/gpu_channel_host.cc ('K') | « services/ui/common/gpu_service.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/ui/common/gpu_service.cc
diff --git a/services/ui/common/gpu_service.cc b/services/ui/common/gpu_service.cc
index f8bf9e79e0939d11ced35b5e1313616fe85c0011..f8535d77976bc54b4de0f9e4fbc9650fea8c3a6e 100644
--- a/services/ui/common/gpu_service.cc
+++ b/services/ui/common/gpu_service.cc
@@ -22,8 +22,10 @@ namespace {
void PostTask(scoped_refptr<base::SingleThreadTaskRunner> runner,
const tracked_objects::Location& from_here,
- const base::Closure& callback) {
- runner->PostTask(from_here, callback);
+ const gpu::GpuChannelEstablishedCallback& callback,
+ scoped_refptr<gpu::GpuChannelHost> established_channel_host) {
+ runner->PostTask(from_here,
+ base::Bind(callback, std::move(established_channel_host)));
}
GpuService* g_gpu_service = nullptr;
@@ -55,11 +57,13 @@ GpuService::~GpuService() {
void GpuService::Initialize(shell::Connector* connector) {
DCHECK(!g_gpu_service);
g_gpu_service = new GpuService(connector);
+ gpu::GpuChannelEstablishFactory::SetInstance(g_gpu_service);
}
// static
void GpuService::Terminate() {
DCHECK(g_gpu_service);
+ gpu::GpuChannelEstablishFactory::SetInstance(nullptr);
delete g_gpu_service;
g_gpu_service = nullptr;
}
@@ -70,11 +74,13 @@ GpuService* GpuService::GetInstance() {
return g_gpu_service;
}
-void GpuService::EstablishGpuChannel(const base::Closure& callback) {
+void GpuService::EstablishGpuChannel(
+ const gpu::GpuChannelEstablishedCallback& callback) {
base::AutoLock auto_lock(lock_);
auto runner = base::ThreadTaskRunnerHandle::Get();
- if (GetGpuChannelLocked()) {
- runner->PostTask(FROM_HERE, callback);
+ scoped_refptr<gpu::GpuChannelHost> channel = GetGpuChannelLocked();
+ if (channel) {
+ PostTask(runner, FROM_HERE, callback, std::move(channel));
return;
}
establish_callbacks_.push_back(
@@ -112,11 +118,6 @@ scoped_refptr<gpu::GpuChannelHost> GpuService::EstablishGpuChannelSync() {
return gpu_channel_;
}
-scoped_refptr<gpu::GpuChannelHost> GpuService::GetGpuChannel() {
- base::AutoLock auto_lock(lock_);
- return GetGpuChannelLocked();
-}
-
scoped_refptr<gpu::GpuChannelHost> GpuService::GetGpuChannelLocked() {
if (gpu_channel_ && gpu_channel_->IsLost()) {
main_task_runner_->PostTask(
@@ -206,7 +207,7 @@ void GpuService::EstablishGpuChannelOnMainThreadDone(
gpu_service_.reset();
for (const auto& i : establish_callbacks_)
- i.Run();
+ i.Run(gpu_channel_);
establish_callbacks_.clear();
}
« gpu/ipc/client/gpu_channel_host.cc ('K') | « services/ui/common/gpu_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698