refactor: migrates util::Promise to gin (#20871)

* refactor: use gin in Promise

* refactor: separate Promise impl that returns nothing

* refactor: use Promise<void> for promise that returns nothing

* fix: methods should be able to run on both browser and renderer process

* fix: should not pass base::StringPiece across threads

* refactor: no more need to use different ResolvePromise for empty Promise

* refactor: move Promise to gin_helper
This commit is contained in:
Cheng Zhao 2019-11-01 15:10:32 +09:00 committed by GitHub
parent bff113760a
commit eaf2c61bef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
48 changed files with 483 additions and 479 deletions

View file

@ -12,7 +12,7 @@
#include "content/browser/gpu/gpu_data_manager_impl.h" // nogncheck
#include "content/public/browser/gpu_data_manager.h"
#include "content/public/browser/gpu_data_manager_observer.h"
#include "shell/common/promise_util.h"
#include "shell/common/gin_helper/promise.h"
namespace electron {
@ -24,8 +24,8 @@ class GPUInfoManager : public content::GpuDataManagerObserver {
GPUInfoManager();
~GPUInfoManager() override;
bool NeedsCompleteGpuInfoCollection() const;
void FetchCompleteInfo(util::Promise<base::DictionaryValue> promise);
void FetchBasicInfo(util::Promise<base::DictionaryValue> promise);
void FetchCompleteInfo(gin_helper::Promise<base::DictionaryValue> promise);
void FetchBasicInfo(gin_helper::Promise<base::DictionaryValue> promise);
void OnGpuInfoUpdate() override;
private:
@ -33,12 +33,13 @@ class GPUInfoManager : public content::GpuDataManagerObserver {
gpu::GPUInfo gpu_info) const;
// These should be posted to the task queue
void CompleteInfoFetcher(util::Promise<base::DictionaryValue> promise);
void CompleteInfoFetcher(gin_helper::Promise<base::DictionaryValue> promise);
void ProcessCompleteInfo();
// This set maintains all the promises that should be fulfilled
// once we have the complete information data
std::vector<util::Promise<base::DictionaryValue>> complete_info_promise_set_;
std::vector<gin_helper::Promise<base::DictionaryValue>>
complete_info_promise_set_;
content::GpuDataManager* gpu_data_manager_;
DISALLOW_COPY_AND_ASSIGN(GPUInfoManager);