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

@ -532,9 +532,10 @@ int ImportIntoCertStore(CertificateManagerModel* model,
}
#endif
void OnIconDataAvailable(util::Promise<gfx::Image> promise, gfx::Image icon) {
void OnIconDataAvailable(gin_helper::Promise<gfx::Image> promise,
gfx::Image icon) {
if (!icon.IsEmpty()) {
promise.ResolveWithGin(icon);
promise.Resolve(icon);
} else {
promise.RejectWithErrorMessage("Failed to get file icon.");
}
@ -1175,7 +1176,7 @@ JumpListResult App::SetJumpList(v8::Local<v8::Value> val,
v8::Local<v8::Promise> App::GetFileIcon(const base::FilePath& path,
gin_helper::Arguments* args) {
util::Promise<gfx::Image> promise(isolate());
gin_helper::Promise<gfx::Image> promise(isolate());
v8::Local<v8::Promise> handle = promise.GetHandle();
base::FilePath normalized_path = path.NormalizePathSeparators();
@ -1193,7 +1194,7 @@ v8::Local<v8::Promise> App::GetFileIcon(const base::FilePath& path,
gfx::Image* icon =
icon_manager->LookupIconFromFilepath(normalized_path, icon_size);
if (icon) {
promise.ResolveWithGin(*icon);
promise.Resolve(*icon);
} else {
icon_manager->LoadIcon(
normalized_path, icon_size,
@ -1285,7 +1286,7 @@ v8::Local<v8::Value> App::GetGPUFeatureStatus(v8::Isolate* isolate) {
v8::Local<v8::Promise> App::GetGPUInfo(v8::Isolate* isolate,
const std::string& info_type) {
auto* const gpu_data_manager = content::GpuDataManagerImpl::GetInstance();
util::Promise<base::DictionaryValue> promise(isolate);
gin_helper::Promise<base::DictionaryValue> promise(isolate);
v8::Local<v8::Promise> handle = promise.GetHandle();
if (info_type != "basic" && info_type != "complete") {
promise.RejectWithErrorMessage(