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 e9c3f3dee36a44d40844a88dbb899f593d03c907..c8dc226ce7c87fa84da5c99760f12538e367bbc9 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 4ed951d5829e87431a1f9f84f0317978cb673e31..82f9a2f97e71848ece8d04effc083db94a45d495 100644
--- a/content/browser/gpu/gpu_data_manager_impl.h
+++ b/content/browser/gpu/gpu_data_manager_impl.h
@@ -124,6 +124,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 53402e4d706f58c26498015c1a5c33b4f7ceabc7..c14ce99ec72881133a5bf2bd90369ee0211f6ca1 100644
--- a/content/browser/gpu/gpu_data_manager_impl_private.cc
+++ b/content/browser/gpu/gpu_data_manager_impl_private.cc
@@ -1215,6 +1215,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 ac0afe687650da564187127dc7ea93a47acde719..237e3f00b1451be43949a797ef1b35885b958a5d 100644
--- a/content/browser/gpu/gpu_data_manager_impl_private.h
+++ b/content/browser/gpu/gpu_data_manager_impl_private.h
@@ -90,6 +90,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);
 
