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.
|
|
|
|
|
2019-06-19 20:56:58 +00:00
|
|
|
#ifndef SHELL_BROWSER_API_GPUINFO_MANAGER_H_
|
|
|
|
#define SHELL_BROWSER_API_GPUINFO_MANAGER_H_
|
2018-09-27 14:59:23 +00:00
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <unordered_set>
|
|
|
|
#include <vector>
|
|
|
|
|
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"
|
2019-06-19 20:46:59 +00:00
|
|
|
#include "shell/common/native_mate_converters/value_converter.h"
|
|
|
|
#include "shell/common/promise_util.h"
|
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
|
|
|
|
class GPUInfoManager : public content::GpuDataManagerObserver {
|
|
|
|
public:
|
|
|
|
static GPUInfoManager* GetInstance();
|
|
|
|
|
|
|
|
GPUInfoManager();
|
|
|
|
~GPUInfoManager() override;
|
2018-10-15 15:26:47 +00:00
|
|
|
bool NeedsCompleteGpuInfoCollection() const;
|
2019-02-21 12:32:44 +00:00
|
|
|
void FetchCompleteInfo(util::Promise promise);
|
|
|
|
void FetchBasicInfo(util::Promise promise);
|
2018-09-27 14:59:23 +00:00
|
|
|
void OnGpuInfoUpdate() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::unique_ptr<base::DictionaryValue> EnumerateGPUInfo(
|
|
|
|
gpu::GPUInfo gpu_info) const;
|
|
|
|
|
|
|
|
// These should be posted to the task queue
|
2019-02-21 12:32:44 +00:00
|
|
|
void CompleteInfoFetcher(util::Promise 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
|
2019-02-21 12:32:44 +00:00
|
|
|
std::vector<util::Promise> complete_info_promise_set_;
|
2018-09-27 14:59:23 +00:00
|
|
|
content::GpuDataManager* gpu_data_manager_;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(GPUInfoManager);
|
|
|
|
};
|
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
} // namespace electron
|
2019-06-19 20:56:58 +00:00
|
|
|
#endif // SHELL_BROWSER_API_GPUINFO_MANAGER_H_
|