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,8 +12,8 @@
#include "mojo/public/cpp/system/data_pipe.h"
#include "mojo/public/cpp/system/simple_watcher.h"
#include "net/base/net_errors.h"
#include "shell/common/gin_helper/promise.h"
#include "shell/common/key_weak_map.h"
#include "shell/common/promise_util.h"
#include "shell/common/node_includes.h"
@ -32,7 +32,7 @@ KeyWeakMap<std::string> g_weak_map;
// Utility class to read from data pipe.
class DataPipeReader {
public:
DataPipeReader(util::Promise<v8::Local<v8::Value>> promise,
DataPipeReader(gin_helper::Promise<v8::Local<v8::Value>> promise,
mojo::Remote<network::mojom::DataPipeGetter> data_pipe_getter)
: promise_(std::move(promise)),
data_pipe_getter_(std::move(data_pipe_getter)),
@ -116,7 +116,7 @@ class DataPipeReader {
delete static_cast<DataPipeReader*>(self);
}
util::Promise<v8::Local<v8::Value>> promise_;
gin_helper::Promise<v8::Local<v8::Value>> promise_;
mojo::Remote<network::mojom::DataPipeGetter> data_pipe_getter_;
mojo::ScopedDataPipeConsumerHandle data_pipe_;
@ -148,7 +148,7 @@ DataPipeHolder::DataPipeHolder(const network::DataElement& element)
DataPipeHolder::~DataPipeHolder() = default;
v8::Local<v8::Promise> DataPipeHolder::ReadAll(v8::Isolate* isolate) {
util::Promise<v8::Local<v8::Value>> promise(isolate);
gin_helper::Promise<v8::Local<v8::Value>> promise(isolate);
v8::Local<v8::Promise> handle = promise.GetHandle();
if (!data_pipe_) {
promise.RejectWithErrorMessage("Could not get blob data");