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

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

Issue 2448983003: gpu: Refactor memory buffer handling code out of content.
Patch Set: . Created 4 years, 1 month 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') | services/ui/public/cpp/mojo_gpu_memory_buffer_manager.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 3fb144944bcf16c57d38a87e20d2f8bcc5b393cf..b650b4d7c2cd8aa459f4a369bf9629c60a820358 100644
--- a/services/ui/public/cpp/gpu_service.cc
+++ b/services/ui/public/cpp/gpu_service.cc
@@ -23,8 +23,7 @@ GpuService::GpuService(service_manager::Connector* connector,
io_task_runner_(std::move(task_runner)),
connector_(connector),
shutdown_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC,
- base::WaitableEvent::InitialState::NOT_SIGNALED),
- gpu_memory_buffer_manager_(new MojoGpuMemoryBufferManager) {
+ base::WaitableEvent::InitialState::NOT_SIGNALED) {
DCHECK(main_task_runner_);
DCHECK(connector_);
if (!io_task_runner_) {
@@ -49,7 +48,16 @@ GpuService::~GpuService() {
std::unique_ptr<GpuService> GpuService::Create(
service_manager::Connector* connector,
scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
- return base::WrapUnique(new GpuService(connector, std::move(task_runner)));
+ auto service =
+ base::WrapUnique(new GpuService(connector, std::move(task_runner)));
+ service->SetUpConnection();
+ return service;
+}
+
+void GpuService::SetUpConnection() {
+ connector_->ConnectToInterface("service:ui", &gpu_service_);
+ gpu_memory_buffer_manager_ =
+ base::MakeUnique<MojoGpuMemoryBufferManager>(gpu_service_.get());
}
void GpuService::EstablishGpuChannel(
@@ -62,10 +70,6 @@ void GpuService::EstablishGpuChannel(
return;
}
establish_callbacks_.push_back(callback);
- if (gpu_service_)
- return;
-
- connector_->ConnectToInterface("service:ui", &gpu_service_);
gpu_service_->EstablishGpuChannel(
base::Bind(&GpuService::OnEstablishedGpuChannel, base::Unretained(this)));
}
@@ -78,7 +82,7 @@ scoped_refptr<gpu::GpuChannelHost> GpuService::EstablishGpuChannelSync() {
int client_id = 0;
mojo::ScopedMessagePipeHandle channel_handle;
gpu::GPUInfo gpu_info;
- connector_->ConnectToInterface("service:ui", &gpu_service_);
+ // connector_->ConnectToInterface("service:ui", &gpu_service_);
mojo::SyncCallRestrictions::ScopedAllowSyncCall allow_sync_call;
if (!gpu_service_->EstablishGpuChannel(&client_id, &channel_handle,
@@ -118,7 +122,6 @@ void GpuService::OnEstablishedGpuChannel(
&shutdown_event_, gpu_memory_buffer_manager_.get());
}
- gpu_service_.reset();
for (const auto& i : establish_callbacks_)
i.Run(gpu_channel_);
establish_callbacks_.clear();
« no previous file with comments | « services/ui/public/cpp/gpu_service.h ('k') | services/ui/public/cpp/mojo_gpu_memory_buffer_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698