refactor: add a wrapper for wrangling uv handles. (#25332)

* refactor: add a wrapper for wrangling uv handles.

Part 1 of a fix for #25248, #22069.

Place the uv_asyncs owned by NodeBindings, ElectronBindings inside a new
UvHandle wrapper class which manages uv_handles' need for their closed()
callback to be invoked before the handles' memory can be freed.

* chore: make lint happy

* refactor: use DCHECK_EQ() instead of DCHECK()

* refactor: fix oops
This commit is contained in:
Charles Kerr 2020-09-13 19:53:50 -05:00 committed by GitHub
parent a3389d017f
commit 70e3aa0182
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 78 additions and 28 deletions

View file

@ -14,6 +14,7 @@
#include "base/process/process_metrics.h"
#include "base/strings/string16.h"
#include "shell/common/gin_helper/promise.h"
#include "shell/common/node_bindings.h"
#include "uv.h" // NOLINT(build/include_directory)
namespace gin_helper {
@ -74,7 +75,7 @@ class ElectronBindings {
bool success,
std::unique_ptr<memory_instrumentation::GlobalMemoryDump> dump);
uv_async_t call_next_tick_async_;
UvHandle<uv_async_t> call_next_tick_async_;
std::list<node::Environment*> pending_next_ticks_;
std::unique_ptr<base::ProcessMetrics> metrics_;