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 bcc2798027aaf132d1bcf526357c8fc65b268c2a..6762c090034f5b29e978bfd9ac0a5677d2b779eb 100644
--- a/content/browser/gpu/gpu_data_manager_impl.cc
+++ b/content/browser/gpu/gpu_data_manager_impl.cc
@@ -230,6 +230,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 dec0836918007eb0d3be46e57cfc92c31af3dc62..9059320a73d27b81fb627753ce5a379470873f33 100644
--- a/content/browser/gpu/gpu_data_manager_impl.h
+++ b/content/browser/gpu/gpu_data_manager_impl.h
@@ -125,6 +125,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 8fbe54453cf26281ba302a7176ad2559cc03bfc7..d83ececfc077e99a287f535435aa447b4406de95 100644
--- a/content/browser/gpu/gpu_data_manager_impl_private.cc
+++ b/content/browser/gpu/gpu_data_manager_impl_private.cc
@@ -1194,6 +1194,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 ed4a3a959ba33fb893ac64b1f965dc3315e78e2c..2023620a79e7267ad5b5859ebf962b747889cdac 100644
--- a/content/browser/gpu/gpu_data_manager_impl_private.h
+++ b/content/browser/gpu/gpu_data_manager_impl_private.h
@@ -87,6 +87,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);
 
