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 7a29221744211227cc1153aad6fee797f5f71134..2a414e5b29791f9fac230555f44129eb1a632719 100644
--- a/content/browser/gpu/gpu_data_manager_impl.cc
+++ b/content/browser/gpu/gpu_data_manager_impl.cc
@@ -214,6 +214,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 08c9940799c935898e02dca5c95b39edbe3fbb32..ced6f932b5bb03d27780d80d158a2eacf206e498 100644
--- a/content/browser/gpu/gpu_data_manager_impl.h
+++ b/content/browser/gpu/gpu_data_manager_impl.h
@@ -117,6 +117,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 ce9a571cf8ca44ced937071047bb5daf2732de2b..8bc154b098c72d5a43af7a638cafb32807cb7468 100644
--- a/content/browser/gpu/gpu_data_manager_impl_private.cc
+++ b/content/browser/gpu/gpu_data_manager_impl_private.cc
@@ -1140,6 +1140,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 f907360160caee6510bb209d71ffa61f0de1e5b9..af68fc04861caf7b050f8afd65bbda0cc8685e45 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 Dx12Requested() const;
   bool VulkanRequested() const;
   void TerminateInfoCollectionGpuProcess();
+  bool DxdiagDx12VulkanRequested() const;
 #endif
   void PostCreateThreads();
   void UpdateDawnInfo(const std::vector<std::string>& dawn_info_list);
