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 0582075df870162a97b463f6b3035a30bcfe36ae..d94c18d16f5ad80f14120c249e83e795c50c5106 100644
--- a/content/browser/gpu/gpu_data_manager_impl.cc
+++ b/content/browser/gpu/gpu_data_manager_impl.cc
@@ -225,6 +225,11 @@ void GpuDataManagerImpl::TerminateInfoCollectionGpuProcess() {
   base::AutoLock auto_lock(lock_);
   private_->TerminateInfoCollectionGpuProcess();
 }
+
+bool GpuDataManagerImpl::DxdiagDx12VulkanRequested() const {
+  base::AutoLock auto_lock(lock_);
+  return private_->DxdiagDx12VulkanRequested();
+}
 #endif  // BUILDFLAG(IS_WIN)
 
 void GpuDataManagerImpl::PostCreateThreads() {
diff --git a/content/browser/gpu/gpu_data_manager_impl.h b/content/browser/gpu/gpu_data_manager_impl.h
index 25896ab0f3ca233ae17bf509f2a6ae5a6cc3c54b..5a8e6d184e276833034c604be8c48e01122207e2 100644
--- a/content/browser/gpu/gpu_data_manager_impl.h
+++ b/content/browser/gpu/gpu_data_manager_impl.h
@@ -121,6 +121,7 @@ class CONTENT_EXPORT GpuDataManagerImpl : public GpuDataManager,
   bool Dx12Requested() const;
   bool VulkanRequested() const;
   void TerminateInfoCollectionGpuProcess();
+  bool DxdiagDx12VulkanRequested() const;
 #endif
   // Called from BrowserMainLoop::PostCreateThreads().
   // TODO(content/browser/gpu/OWNERS): This should probably use a
diff --git a/content/browser/gpu/gpu_data_manager_impl_private.cc b/content/browser/gpu/gpu_data_manager_impl_private.cc
index 4fa857fed71485898f4ba7c6e78cc8be37d8dbf7..c12a96390350b5bd14a43506d8a35e4b0dec4924 100644
--- a/content/browser/gpu/gpu_data_manager_impl_private.cc
+++ b/content/browser/gpu/gpu_data_manager_impl_private.cc
@@ -1222,6 +1222,10 @@ void GpuDataManagerImplPrivate::TerminateInfoCollectionGpuProcess() {
   if (host)
     host->ForceShutdown();
 }
+
+bool GpuDataManagerImplPrivate::DxdiagDx12VulkanRequested() const {
+  return !(gpu_info_vulkan_request_failed_ || gpu_info_dx12_request_failed_);
+}
 #endif
 
 void GpuDataManagerImplPrivate::PostCreateThreads() {
diff --git a/content/browser/gpu/gpu_data_manager_impl_private.h b/content/browser/gpu/gpu_data_manager_impl_private.h
index 20e883daaa07133f977c5fe0c822f324d2642793..28306624ec6f7f9a7848e65787d4dc5aa738a76c 100644
--- a/content/browser/gpu/gpu_data_manager_impl_private.h
+++ b/content/browser/gpu/gpu_data_manager_impl_private.h
@@ -86,6 +86,7 @@ class CONTENT_EXPORT GpuDataManagerImplPrivate {
   bool Dx12Requested() const;
   bool VulkanRequested() const;
   void TerminateInfoCollectionGpuProcess();
+  bool DxdiagDx12VulkanRequested() const;
 #endif
   void PostCreateThreads();
   void UpdateDawnInfo(const std::vector<std::string>& dawn_info_list);
