2018-09-27 14:59:23 +00:00
|
|
|
// Copyright (c) 2018 GitHub, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#ifndef ELECTRON_SHELL_BROWSER_API_GPUINFO_MANAGER_H_
|
|
|
|
#define ELECTRON_SHELL_BROWSER_API_GPUINFO_MANAGER_H_
|
2018-09-27 14:59:23 +00:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
2023-05-11 20:07:39 +00:00
|
|
|
#include "base/memory/raw_ptr.h"
|
2019-03-05 05:08:55 +00:00
|
|
|
#include "content/browser/gpu/gpu_data_manager_impl.h" // nogncheck
|
2018-09-27 14:59:23 +00:00
|
|
|
#include "content/public/browser/gpu_data_manager.h"
|
|
|
|
#include "content/public/browser/gpu_data_manager_observer.h"
|
2024-07-29 17:42:57 +00:00
|
|
|
|
|
|
|
namespace gin_helper {
|
|
|
|
template <typename T>
|
|
|
|
class Promise;
|
|
|
|
} // namespace gin_helper
|
2018-09-27 14:59:23 +00:00
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
namespace electron {
|
2018-09-27 14:59:23 +00:00
|
|
|
|
|
|
|
// GPUInfoManager is a singleton used to manage and fetch GPUInfo
|
2024-05-21 19:21:31 +00:00
|
|
|
class GPUInfoManager : private content::GpuDataManagerObserver {
|
2018-09-27 14:59:23 +00:00
|
|
|
public:
|
|
|
|
static GPUInfoManager* GetInstance();
|
|
|
|
|
|
|
|
GPUInfoManager();
|
|
|
|
~GPUInfoManager() override;
|
2021-11-03 11:41:45 +00:00
|
|
|
|
|
|
|
// disable copy
|
|
|
|
GPUInfoManager(const GPUInfoManager&) = delete;
|
|
|
|
GPUInfoManager& operator=(const GPUInfoManager&) = delete;
|
|
|
|
|
2022-06-28 16:52:59 +00:00
|
|
|
void FetchCompleteInfo(gin_helper::Promise<base::Value> promise);
|
|
|
|
void FetchBasicInfo(gin_helper::Promise<base::Value> promise);
|
2018-09-27 14:59:23 +00:00
|
|
|
|
|
|
|
private:
|
2024-06-20 08:49:07 +00:00
|
|
|
// content::GpuDataManagerObserver
|
2024-05-21 19:21:31 +00:00
|
|
|
void OnGpuInfoUpdate() override;
|
|
|
|
|
2022-06-28 16:52:59 +00:00
|
|
|
base::Value::Dict EnumerateGPUInfo(gpu::GPUInfo gpu_info) const;
|
2018-09-27 14:59:23 +00:00
|
|
|
|
|
|
|
// These should be posted to the task queue
|
2022-06-28 16:52:59 +00:00
|
|
|
void CompleteInfoFetcher(gin_helper::Promise<base::Value> promise);
|
2018-09-27 14:59:23 +00:00
|
|
|
void ProcessCompleteInfo();
|
|
|
|
|
|
|
|
// This set maintains all the promises that should be fulfilled
|
|
|
|
// once we have the complete information data
|
2022-06-28 16:52:59 +00:00
|
|
|
std::vector<gin_helper::Promise<base::Value>> complete_info_promise_set_;
|
2023-05-11 20:07:39 +00:00
|
|
|
raw_ptr<content::GpuDataManagerImpl> gpu_data_manager_;
|
2018-09-27 14:59:23 +00:00
|
|
|
};
|
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
} // namespace electron
|
2021-11-22 07:34:31 +00:00
|
|
|
#endif // ELECTRON_SHELL_BROWSER_API_GPUINFO_MANAGER_H_
|