electron/shell/common/process_util.cc

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

56 lines
1.5 KiB
C++
Raw Normal View History

// Copyright (c) 2019 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "shell/common/process_util.h"
chore: bump chromium to 129.0.6616.0 (main) (#43012) * chore: bump chromium in DEPS to 128.0.6613.0 * chore: 5725076: Update EventType names | https://chromium-review.googlesource.com/c/chromium/src/+/5725076 * chore: export patches * chore: 5725076: Update EventType names | https://chromium-review.googlesource.com/c/chromium/src/+/5725076 for windows * chore: bump chromium in DEPS to 129.0.6614.0 * 5725672: Add a feature to limit the number of preconnect in LoadingPredictor | https://chromium-review.googlesource.com/c/chromium/src/+/5725672 * chore: bump chromium in DEPS to 129.0.6616.0 * chore: e patches all and resolve conflict in patches/v8/fix_disable_scope_reuse_associated_dchecks.patch * 5730656: Show an error dialog when UpdatePrintSettings() fails | https://chromium-review.googlesource.com/c/chromium/src/+/5730656 * chore: gen-libc++-filenames * 5729956: Finally remove string_piece.h | https://chromium-review.googlesource.com/c/chromium/src/+/5729956 * chore: replace all references of base::StringPiece with std::string_view * chore: remove more references of stringPiece in favor of string_view * chore: rename string_piece variables to string_view * 5508795: Remove the NotificationService | https://chromium-review.googlesource.com/c/chromium/src/+/5508795 * 5734053: Revert Rename GlobalFeatures to GlobalDesktopFeatures. | https://chromium-review.googlesource.com/c/chromium/src/+/5734053 * chore: resolve conflict with main without merge --------- Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: Alice Zhao <alice@makenotion.com>
2024-07-29 13:37:35 +00:00
#include <string_view>
#include "base/command_line.h"
#include "content/public/common/content_switches.h"
#include "gin/dictionary.h"
#include "shell/common/gin_converters/callback_converter.h"
#include "shell/common/node_includes.h"
namespace electron {
void EmitWarning(node::Environment* env,
const std::string& warning_msg,
const std::string& warning_type) {
v8::HandleScope scope(env->isolate());
gin::Dictionary process(env->isolate(), env->process_object());
chore: bump chromium to 129.0.6616.0 (main) (#43012) * chore: bump chromium in DEPS to 128.0.6613.0 * chore: 5725076: Update EventType names | https://chromium-review.googlesource.com/c/chromium/src/+/5725076 * chore: export patches * chore: 5725076: Update EventType names | https://chromium-review.googlesource.com/c/chromium/src/+/5725076 for windows * chore: bump chromium in DEPS to 129.0.6614.0 * 5725672: Add a feature to limit the number of preconnect in LoadingPredictor | https://chromium-review.googlesource.com/c/chromium/src/+/5725672 * chore: bump chromium in DEPS to 129.0.6616.0 * chore: e patches all and resolve conflict in patches/v8/fix_disable_scope_reuse_associated_dchecks.patch * 5730656: Show an error dialog when UpdatePrintSettings() fails | https://chromium-review.googlesource.com/c/chromium/src/+/5730656 * chore: gen-libc++-filenames * 5729956: Finally remove string_piece.h | https://chromium-review.googlesource.com/c/chromium/src/+/5729956 * chore: replace all references of base::StringPiece with std::string_view * chore: remove more references of stringPiece in favor of string_view * chore: rename string_piece variables to string_view * 5508795: Remove the NotificationService | https://chromium-review.googlesource.com/c/chromium/src/+/5508795 * 5734053: Revert Rename GlobalFeatures to GlobalDesktopFeatures. | https://chromium-review.googlesource.com/c/chromium/src/+/5734053 * chore: resolve conflict with main without merge --------- Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: Alice Zhao <alice@makenotion.com>
2024-07-29 13:37:35 +00:00
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, "");
}
std::string GetProcessType() {
auto* command_line = base::CommandLine::ForCurrentProcess();
return command_line->GetSwitchValueASCII(switches::kProcessType);
}
bool IsBrowserProcess() {
static bool result = GetProcessType().empty();
return result;
}
bool IsRendererProcess() {
static bool result = GetProcessType() == switches::kRendererProcess;
return result;
}
bool IsUtilityProcess() {
static bool result = GetProcessType() == switches::kUtilityProcess;
return result;
}
bool IsZygoteProcess() {
static bool result = GetProcessType() == switches::kZygoteProcess;
return result;
}
} // namespace electron