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:
Charles Kerr 2024-09-16 15:53:04 -05:00 committed by GitHub
parent 7d4f202c1c
commit 05dfd14913
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 72 additions and 89 deletions

View file

@ -12,14 +12,14 @@
#include "base/command_line.h"
#include "base/environment.h"
#include "base/no_destructor.h"
#include "base/strings/stringprintf.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "components/crash/core/common/crash_key.h"
#include "content/public/common/content_switches.h"
#include "electron/buildflags/buildflags.h"
#include "electron/fuses.h"
#include "shell/browser/javascript_environment.h"
#include "shell/common/electron_constants.h"
#include "shell/common/node_includes.h"
#include "shell/common/node_util.h"
#include "shell/common/options_switches.h"
#include "shell/common/process_util.h"
#include "third_party/crashpad/crashpad/client/annotation.h"
@ -54,13 +54,10 @@ void SetCrashKey(const std::string& key, const std::string& value) {
// Chrome DCHECK()s if we try to set an annotation with a name longer than
// the max.
if (key.size() >= kMaxCrashKeyNameLength) {
node::Environment* env =
node::Environment::GetCurrent(JavascriptEnvironment::GetIsolate());
EmitWarning(
env,
base::StringPrintf("The crash key name, \"%s\", is longer than %" PRIu32
" bytes, ignoring it.",
key.c_str(), kMaxCrashKeyNameLength),
util::EmitWarning(
base::StrCat({"The crash key name, '", key, "', is longer than ",
base::NumberToString(kMaxCrashKeyNameLength),
" bytes, ignoring it."}),
"electron");
return;
}