mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
refactor: add EmitWarning(v8::Isolate*) helper (#43722)
* refactor: add EmitWarning(Isolate*, ...) warning * chore: remove EmitWarning(node::Environment*, ...) * chore: add code comments * fixup! refactor: add EmitWarning(Isolate*, ...) warning * chore: remove unused node #includes
This commit is contained in:
@@ -6,6 +6,9 @@
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "gin/converter.h"
|
||||
#include "gin/dictionary.h"
|
||||
#include "shell/browser/javascript_environment.h"
|
||||
#include "shell/common/gin_converters/callback_converter.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
|
||||
namespace electron::util {
|
||||
@@ -44,4 +47,22 @@ v8::MaybeLocal<v8::Value> CompileAndCall(
|
||||
return ret;
|
||||
}
|
||||
|
||||
void EmitWarning(const std::string_view warning_msg,
|
||||
const std::string_view warning_type) {
|
||||
EmitWarning(JavascriptEnvironment::GetIsolate(), warning_msg, warning_type);
|
||||
}
|
||||
|
||||
void EmitWarning(v8::Isolate* isolate,
|
||||
const std::string_view warning_msg,
|
||||
const std::string_view warning_type) {
|
||||
v8::HandleScope scope{isolate};
|
||||
gin::Dictionary process{
|
||||
isolate, node::Environment::GetCurrent(isolate)->process_object()};
|
||||
base::RepeatingCallback<void(std::string_view, std::string_view,
|
||||
std::string_view)>
|
||||
emit_warning;
|
||||
process.Get("emitWarning", &emit_warning);
|
||||
emit_warning.Run(warning_msg, warning_type, "");
|
||||
}
|
||||
|
||||
} // namespace electron::util
|
||||
|
||||
Reference in New Issue
Block a user