Index: services/ui/ws/gpu_service_proxy.cc |
diff --git a/services/ui/ws/gpu_service_proxy.cc b/services/ui/ws/gpu_service_proxy.cc |
index d5815458845b42e44dff7f38b60c355b79bbedef..ec24addb8e86db7f1dfcfd731e2ba11b38f764a1 100644 |
--- a/services/ui/ws/gpu_service_proxy.cc |
+++ b/services/ui/ws/gpu_service_proxy.cc |
@@ -43,6 +43,10 @@ class GpuServiceImpl : public mojom::GpuService { |
} |
~GpuServiceImpl() override {} |
+ void reset_gpu_service_internal(mojom::GpuServiceInternal* connection) { |
+ gpu_service_internal_ = connection; |
+ } |
+ |
private: |
void OnGpuChannelEstablished(const EstablishGpuChannelCallback& callback, |
mojo::ScopedMessagePipeHandle channel_handle) { |
@@ -101,6 +105,9 @@ GpuServiceProxy::GpuServiceProxy(GpuServiceProxyDelegate* delegate) |
// TODO(sad): Once GPU process is split, this would look like: |
// connector->ConnectToInterface("gpu", &gpu_service_); |
gpu_main_.Create(GetProxy(&gpu_service_)); |
+ gpu_service_.set_connection_error_handler( |
+ base::Bind(&GpuServiceProxy::OnGpuConnectionGone, |
+ base::Unretained(this))); |
gpu_service_->Initialize( |
base::Bind(&GpuServiceProxy::OnInitialized, base::Unretained(this))); |
gpu_memory_buffer_manager_ = base::MakeUnique<MusGpuMemoryBufferManager>( |
@@ -111,11 +118,11 @@ GpuServiceProxy::~GpuServiceProxy() { |
} |
void GpuServiceProxy::Add(mojom::GpuServiceRequest request) { |
- mojo::MakeStrongBinding( |
+ clients_.push_back(mojo::MakeStrongBinding( |
base::MakeUnique<GpuServiceImpl>(next_client_id_++, &gpu_info_, |
gpu_memory_buffer_manager_.get(), |
gpu_service_.get()), |
- std::move(request)); |
+ std::move(request))); |
} |
void GpuServiceProxy::CreateDisplayCompositor( |
@@ -129,5 +136,18 @@ void GpuServiceProxy::OnInitialized(const gpu::GPUInfo& gpu_info) { |
delegate_->OnGpuServiceInitialized(); |
} |
+void GpuServiceProxy::OnGpuConnectionGone() { |
+ // TODO(sad): Once GPU process is split, this would look like: |
+ // connector->ConnectToInterface("gpu", &gpu_service_); |
+ gpu_main_.Create(GetProxy(&gpu_service_)); |
+ gpu_service_.set_connection_error_handler( |
+ base::Bind(&GpuServiceProxy::OnGpuConnectionGone, |
+ base::Unretained(this))); |
+ for (auto& weak_ptr : clients_) { |
+ GpuServiceImpl* client = static_cast<GpuServiceImpl*>(weak_ptr->impl()); |
+ client->reset_gpu_service_internal(gpu_service_.get()); |
+ } |
+} |
+ |
} // namespace ws |
} // namespace ui |