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

@ -47,7 +47,7 @@ void GPUInfoManager::ProcessCompleteInfo() {
// We have received the complete information, resolve all promises that
// were waiting for this info.
for (auto& promise : complete_info_promise_set_) {
promise.ResolveWithGin(*result);
promise.Resolve(*result);
}
complete_info_promise_set_.clear();
}
@ -63,7 +63,7 @@ void GPUInfoManager::OnGpuInfoUpdate() {
// Should be posted to the task runner
void GPUInfoManager::CompleteInfoFetcher(
util::Promise<base::DictionaryValue> promise) {
gin_helper::Promise<base::DictionaryValue> promise) {
complete_info_promise_set_.emplace_back(std::move(promise));
if (NeedsCompleteGpuInfoCollection()) {
@ -75,7 +75,7 @@ void GPUInfoManager::CompleteInfoFetcher(
}
void GPUInfoManager::FetchCompleteInfo(
util::Promise<base::DictionaryValue> promise) {
gin_helper::Promise<base::DictionaryValue> promise) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(&GPUInfoManager::CompleteInfoFetcher,
base::Unretained(this), std::move(promise)));
@ -84,10 +84,10 @@ void GPUInfoManager::FetchCompleteInfo(
// This fetches the info synchronously, so no need to post to the task queue.
// There cannot be multiple promises as they are resolved synchronously.
void GPUInfoManager::FetchBasicInfo(
util::Promise<base::DictionaryValue> promise) {
gin_helper::Promise<base::DictionaryValue> promise) {
gpu::GPUInfo gpu_info;
CollectBasicGraphicsInfo(&gpu_info);
promise.ResolveWithGin(*EnumerateGPUInfo(gpu_info));
promise.Resolve(*EnumerateGPUInfo(gpu_info));
}
std::unique_ptr<base::DictionaryValue> GPUInfoManager::EnumerateGPUInfo(