gpuinfo_manager.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright (c) 2018 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #ifndef SHELL_BROWSER_API_GPUINFO_MANAGER_H_
  5. #define SHELL_BROWSER_API_GPUINFO_MANAGER_H_
  6. #include <memory>
  7. #include <unordered_set>
  8. #include <vector>
  9. #include "content/browser/gpu/gpu_data_manager_impl.h" // nogncheck
  10. #include "content/public/browser/gpu_data_manager.h"
  11. #include "content/public/browser/gpu_data_manager_observer.h"
  12. #include "shell/common/native_mate_converters/value_converter.h"
  13. #include "shell/common/promise_util.h"
  14. namespace electron {
  15. // GPUInfoManager is a singleton used to manage and fetch GPUInfo
  16. class GPUInfoManager : public content::GpuDataManagerObserver {
  17. public:
  18. static GPUInfoManager* GetInstance();
  19. GPUInfoManager();
  20. ~GPUInfoManager() override;
  21. bool NeedsCompleteGpuInfoCollection() const;
  22. void FetchCompleteInfo(util::Promise promise);
  23. void FetchBasicInfo(util::Promise promise);
  24. void OnGpuInfoUpdate() override;
  25. private:
  26. std::unique_ptr<base::DictionaryValue> EnumerateGPUInfo(
  27. gpu::GPUInfo gpu_info) const;
  28. // These should be posted to the task queue
  29. void CompleteInfoFetcher(util::Promise promise);
  30. void ProcessCompleteInfo();
  31. // This set maintains all the promises that should be fulfilled
  32. // once we have the complete information data
  33. std::vector<util::Promise> complete_info_promise_set_;
  34. content::GpuDataManager* gpu_data_manager_;
  35. DISALLOW_COPY_AND_ASSIGN(GPUInfoManager);
  36. };
  37. } // namespace electron
  38. #endif // SHELL_BROWSER_API_GPUINFO_MANAGER_H_