| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3ecfe9d commit 8a2ce5d
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -479,6 +479,8 @@ constexpr size_t kFsStatsBufferLength = | |||
| 479 | 479 | V(internal_binding_loader, v8::Function) \ | |
| 480 | 480 | V(immediate_callback_function, v8::Function) \ | |
| 481 | 481 | V(inspector_console_extension_installer, v8::Function) \ | |
| 482 | + V(inspector_disable_async_hooks, v8::Function) \ | ||
| 483 | + V(inspector_enable_async_hooks, v8::Function) \ | ||
| 482 | 484 | V(messaging_deserialize_create_object, v8::Function) \ | |
| 483 | 485 | V(message_port, v8::Object) \ | |
| 484 | 486 | V(native_module_require, v8::Function) \ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -40,7 +40,6 @@ using node::FatalError; | |||
| 40 | 40 | ||
| 41 | 41 | using v8::Context; | |
| 42 | 42 | using v8::Function; | |
| 43 | - using v8::Global; | ||
| 44 | 43 | using v8::HandleScope; | |
| 45 | 44 | using v8::Isolate; | |
| 46 | 45 | using v8::Local; | |
@@ -804,8 +803,8 @@ void Agent::PauseOnNextJavascriptStatement(const std::string& reason) { | |||
| 804 | 803 | void Agent::RegisterAsyncHook(Isolate* isolate, | |
| 805 | 804 | Local<Function> enable_function, | |
| 806 | 805 | Local<Function> disable_function) { | |
| 807 | - enable_async_hook_function_.Reset(isolate, enable_function); | ||
| 808 | - disable_async_hook_function_.Reset(isolate, disable_function); | ||
| 806 | + parent_env_->set_inspector_enable_async_hooks(enable_function); | ||
| 807 | + parent_env_->set_inspector_disable_async_hooks(disable_function); | ||
| 809 | 808 | if (pending_enable_async_hook_) { | |
| 810 | 809 | CHECK(!pending_disable_async_hook_); | |
| 811 | 810 | pending_enable_async_hook_ = false; | |
@@ -818,8 +817,10 @@ void Agent::RegisterAsyncHook(Isolate* isolate, | |||
| 818 | 817 | } | |
| 819 | 818 | ||
| 820 | 819 | void Agent::EnableAsyncHook() { | |
| 821 | - if (!enable_async_hook_function_.IsEmpty()) { | ||
| 822 | - ToggleAsyncHook(parent_env_->isolate(), enable_async_hook_function_); | ||
| 820 | + HandleScope scope(parent_env_->isolate()); | ||
| 821 | + Local<Function> enable = parent_env_->inspector_enable_async_hooks(); | ||
| 822 | + if (!enable.IsEmpty()) { | ||
| 823 | + ToggleAsyncHook(parent_env_->isolate(), enable); | ||
| 823 | 824 | } else if (pending_disable_async_hook_) { | |
| 824 | 825 | CHECK(!pending_enable_async_hook_); | |
| 825 | 826 | pending_disable_async_hook_ = false; | |
@@ -829,8 +830,10 @@ void Agent::EnableAsyncHook() { | |||
| 829 | 830 | } | |
| 830 | 831 | ||
| 831 | 832 | void Agent::DisableAsyncHook() { | |
| 832 | - if (!disable_async_hook_function_.IsEmpty()) { | ||
| 833 | - ToggleAsyncHook(parent_env_->isolate(), disable_async_hook_function_); | ||
| 833 | + HandleScope scope(parent_env_->isolate()); | ||
| 834 | + Local<Function> disable = parent_env_->inspector_enable_async_hooks(); | ||
| 835 | + if (!disable.IsEmpty()) { | ||
| 836 | + ToggleAsyncHook(parent_env_->isolate(), disable); | ||
| 834 | 837 | } else if (pending_enable_async_hook_) { | |
| 835 | 838 | CHECK(!pending_disable_async_hook_); | |
| 836 | 839 | pending_enable_async_hook_ = false; | |
@@ -839,8 +842,7 @@ void Agent::DisableAsyncHook() { | |||
| 839 | 842 | } | |
| 840 | 843 | } | |
| 841 | 844 | ||
| 842 | - void Agent::ToggleAsyncHook(Isolate* isolate, | ||
| 843 | - const Global<Function>& fn) { | ||
| 845 | + void Agent::ToggleAsyncHook(Isolate* isolate, Local<Function> fn) { | ||
| 844 | 846 | // Guard against running this during cleanup -- no async events will be | |
| 845 | 847 | // emitted anyway at that point anymore, and calling into JS is not possible. | |
| 846 | 848 | // This should probably not be something we're attempting in the first place, | |
@@ -851,7 +853,7 @@ void Agent::ToggleAsyncHook(Isolate* isolate, | |||
| 851 | 853 | CHECK(!fn.IsEmpty()); | |
| 852 | 854 | auto context = parent_env_->context(); | |
| 853 | 855 | v8::TryCatch try_catch(isolate); | |
| 854 | - USE(fn.Get(isolate)->Call(context, Undefined(isolate), 0, nullptr)); | ||
| 856 | + USE(fn->Call(context, Undefined(isolate), 0, nullptr)); | ||
| 855 | 857 | if (try_catch.HasCaught() && !try_catch.HasTerminated()) { | |
| 856 | 858 | PrintCaughtException(isolate, context, try_catch); | |
| 857 | 859 | FatalError("\nnode::inspector::Agent::ToggleAsyncHook", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -117,8 +117,7 @@ class Agent { | |||
| 117 | 117 | inline Environment* env() const { return parent_env_; } | |
| 118 | 118 | ||
| 119 | 119 | private: | |
| 120 | - void ToggleAsyncHook(v8::Isolate* isolate, | ||
| 121 | - const v8::Global<v8::Function>& fn); | ||
| 120 | + void ToggleAsyncHook(v8::Isolate* isolate, v8::Local<v8::Function> fn); | ||
| 122 | 121 | ||
| 123 | 122 | node::Environment* parent_env_; | |
| 124 | 123 | // Encapsulates majority of the Inspector functionality | |
@@ -137,8 +136,6 @@ class Agent { | |||
| 137 | 136 | ||
| 138 | 137 | bool pending_enable_async_hook_ = false; | |
| 139 | 138 | bool pending_disable_async_hook_ = false; | |
| 140 | - v8::Global<v8::Function> enable_async_hook_function_; | ||
| 141 | - v8::Global<v8::Function> disable_async_hook_function_; | ||
| 142 | 139 | }; | |
| 143 | 140 | ||
| 144 | 141 | } // namespace inspector | |
| Back | FazBrowse Home | New Git URL |
0 commit comments