chore: clean up promise resoution with helpers (#17268)

This commit is contained in:
Shelley Vohr 2019-03-13 14:30:21 -07:00 committed by GitHub
parent 3e5a98b5f4
commit d9234798d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 26 additions and 52 deletions

View file

@ -177,10 +177,6 @@ bool IsProtocolHandledInIO(
return is_handled;
}
void PromiseCallback(util::Promise promise, bool handled) {
promise.Resolve(handled);
}
v8::Local<v8::Promise> Protocol::IsProtocolHandled(const std::string& scheme) {
util::Promise promise(isolate());
v8::Local<v8::Promise> handle = promise.GetHandle();
@ -190,7 +186,7 @@ v8::Local<v8::Promise> Protocol::IsProtocolHandled(const std::string& scheme) {
base::PostTaskWithTraitsAndReplyWithResult(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(&IsProtocolHandledInIO, base::RetainedRef(getter), scheme),
base::BindOnce(&PromiseCallback, std::move(promise)));
base::BindOnce(util::Promise::ResolvePromise<bool>, std::move(promise)));
return handle;
}