diff --git a/src/node.h b/src/node.h index 3a3dba9fd23a7b..3103750558aba7 100644 --- a/src/node.h +++ b/src/node.h @@ -761,84 +761,84 @@ v8::MaybeLocal MakeCallback(v8::Isolate* isolate, * `AsyncResource::MakeCallback()` is used, then all four callbacks will be * called automatically. */ class AsyncResource { - public: - AsyncResource(v8::Isolate* isolate, - v8::Local resource, - const char* name, - async_id trigger_async_id = -1) - : isolate_(isolate), - resource_(isolate, resource) { - async_context_ = EmitAsyncInit(isolate, resource, name, - trigger_async_id); - } - - AsyncResource(v8::Isolate* isolate, - v8::Local resource, - v8::Local name, - async_id trigger_async_id = -1) - : isolate_(isolate), - resource_(isolate, resource) { - async_context_ = EmitAsyncInit(isolate, resource, name, - trigger_async_id); - } - - virtual ~AsyncResource() { - EmitAsyncDestroy(isolate_, async_context_); - resource_.Reset(); - } - - v8::MaybeLocal MakeCallback( - v8::Local callback, - int argc, - v8::Local* argv) { - return node::MakeCallback(isolate_, get_resource(), - callback, argc, argv, - async_context_); - } - - v8::MaybeLocal MakeCallback( - const char* method, - int argc, - v8::Local* argv) { - return node::MakeCallback(isolate_, get_resource(), - method, argc, argv, - async_context_); - } - - v8::MaybeLocal MakeCallback( - v8::Local symbol, - int argc, - v8::Local* argv) { - return node::MakeCallback(isolate_, get_resource(), - symbol, argc, argv, - async_context_); - } - - v8::Local get_resource() { - return resource_.Get(isolate_); - } - - async_id get_async_id() const { - return async_context_.async_id; - } - - async_id get_trigger_async_id() const { - return async_context_.trigger_async_id; - } - - protected: - class CallbackScope : public node::CallbackScope { - public: - explicit CallbackScope(AsyncResource* res) - : node::CallbackScope(res->isolate_, - res->resource_.Get(res->isolate_), - res->async_context_) {} - }; - - private: - v8::Isolate* isolate_; - v8::Persistent resource_; - async_context async_context_; + public: + AsyncResource(v8::Isolate* isolate, + v8::Local resource, + const char* name, + async_id trigger_async_id = -1) + : isolate_(isolate), + resource_(isolate, resource) { + async_context_ = EmitAsyncInit(isolate, resource, name, + trigger_async_id); + } + + AsyncResource(v8::Isolate* isolate, + v8::Local resource, + v8::Local name, + async_id trigger_async_id = -1) + : isolate_(isolate), + resource_(isolate, resource) { + async_context_ = EmitAsyncInit(isolate, resource, name, + trigger_async_id); + } + + virtual ~AsyncResource() { + EmitAsyncDestroy(isolate_, async_context_); + resource_.Reset(); + } + + v8::MaybeLocal MakeCallback( + v8::Local callback, + int argc, + v8::Local* argv) { + return node::MakeCallback(isolate_, get_resource(), + callback, argc, argv, + async_context_); + } + + v8::MaybeLocal MakeCallback( + const char* method, + int argc, + v8::Local* argv) { + return node::MakeCallback(isolate_, get_resource(), + method, argc, argv, + async_context_); + } + + v8::MaybeLocal MakeCallback( + v8::Local symbol, + int argc, + v8::Local* argv) { + return node::MakeCallback(isolate_, get_resource(), + symbol, argc, argv, + async_context_); + } + + v8::Local get_resource() { + return resource_.Get(isolate_); + } + + async_id get_async_id() const { + return async_context_.async_id; + } + + async_id get_trigger_async_id() const { + return async_context_.trigger_async_id; + } + + protected: + class CallbackScope : public node::CallbackScope { + public: + explicit CallbackScope(AsyncResource* res) + : node::CallbackScope(res->isolate_, + res->resource_.Get(res->isolate_), + res->async_context_) {} + }; + + private: + v8::Isolate* isolate_; + v8::Persistent resource_; + async_context async_context_; }; } // namespace node