From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Deepak Mohan <hop2deep@gmail.com>
Date: Fri, 28 Feb 2020 15:08:26 -0800
Subject: gpu: notify when dxdiag request for gpu info fails

We rely on the signal OnGpuInfoUpdate to process gpu info.
When Electron wants to collect the complete info in a single run
it checks for the presence of dx_diagnostics attribute, as these
are the only async calls that happens in the gpu process, but
there are times when this call can fail due to crash or software
rendering and there is no signal from browser process on this event
to identify it.

diff --git a/content/browser/gpu/gpu_data_manager_impl.cc b/content/browser/gpu/gpu_data_manager_impl.cc
index 7821945da13ece57529c1de14d1cbd7f645d19ab..9be940f4ee047279f5969a6c572d6acbd408ddc5 100644
--- a/content/browser/gpu/gpu_data_manager_impl.cc
+++ b/content/browser/gpu/gpu_data_manager_impl.cc
@@ -229,6 +229,11 @@ void GpuDataManagerImpl::TerminateInfoCollectionGpuProcess() {
   base::AutoLock auto_lock(lock_);
   private_->TerminateInfoCollectionGpuProcess();
 }
+
+bool GpuDataManagerImpl::DxdiagDx12VulkanRequested() const {
+  base::AutoLock auto_lock(lock_);
+  return private_->DxdiagDx12VulkanRequested();
+}
 #endif
 
 void GpuDataManagerImpl::UpdateDawnInfo(
diff --git a/content/browser/gpu/gpu_data_manager_impl.h b/content/browser/gpu/gpu_data_manager_impl.h
index a8c0d59cb825a791c44c54e55ad7f295ad07a309..a1ef53aa46fb0cfc7bcac121244f77af64a7539f 100644
--- a/content/browser/gpu/gpu_data_manager_impl.h
+++ b/content/browser/gpu/gpu_data_manager_impl.h
@@ -122,6 +122,7 @@ class CONTENT_EXPORT GpuDataManagerImpl : public GpuDataManager,
   // BrowserMainParts override instead.
   void PostCreateThreads();
   void TerminateInfoCollectionGpuProcess();
+  bool DxdiagDx12VulkanRequested() const;
 #endif
   void UpdateDawnInfo(const std::vector<std::string>& dawn_info_list);
 
diff --git a/content/browser/gpu/gpu_data_manager_impl_private.cc b/content/browser/gpu/gpu_data_manager_impl_private.cc
index 569c179aed6ab7b68b484f55d0abf9562044c389..9612ed45ed7d987c5d4e8f7ef348860ab4fc4252 100644
--- a/content/browser/gpu/gpu_data_manager_impl_private.cc
+++ b/content/browser/gpu/gpu_data_manager_impl_private.cc
@@ -1219,6 +1219,12 @@ void GpuDataManagerImplPrivate::TerminateInfoCollectionGpuProcess() {
   if (host)
     host->ForceShutdown();
 }
+
+bool GpuDataManagerImplPrivate::DxdiagDx12VulkanRequested() const {
+  return !(gpu_info_vulkan_request_failed_ ||
+           gpu_info_dx12_request_failed_ ||
+           gpu_info_dx_diag_request_failed_);
+}
 #endif
 
 void GpuDataManagerImplPrivate::UpdateDawnInfo(
diff --git a/content/browser/gpu/gpu_data_manager_impl_private.h b/content/browser/gpu/gpu_data_manager_impl_private.h
index afd9e892bd94314b5dc979dadf6fd91f8ad9ff04..02134414e3bab125697b5f3080af2c90d4cee07c 100644
--- a/content/browser/gpu/gpu_data_manager_impl_private.h
+++ b/content/browser/gpu/gpu_data_manager_impl_private.h
@@ -84,6 +84,7 @@ class CONTENT_EXPORT GpuDataManagerImplPrivate {
   bool VulkanRequested() const;
   void PostCreateThreads();
   void TerminateInfoCollectionGpuProcess();
+  bool DxdiagDx12VulkanRequested() const;
 #endif
   void UpdateDawnInfo(const std::vector<std::string>& dawn_info_list);
 
