refactor: prefer inline constexpr string_view
for string constants (#44405)
* refactor: BaseWindow::OnExecuteAppCommand() now takes a std::string_view * refactor: NativeWindow::NotifyWindowExecuteAppCommand() takes a std::string_view * refactor: AppCommandToString() returns a std::string_view, is now constexpr * refactor: make kBrowserBackward, kBrowserForward inline constexpr std::string_view Xref: https://abseil.io/tips/140 https://groups.google.com/a/chromium.org/g/chromium-dev/c/jROTxMo_m2Q/m/HgciN2KsAgAJ * refactor: use inline constexpr string_view for kDevice*Key constants Xref: https://abseil.io/tips/140 https://groups.google.com/a/chromium.org/g/chromium-dev/c/jROTxMo_m2Q/m/HgciN2KsAgAJ * refactor: IsEnvSet now takes a base::cstring_view * refactor: use inline constexpr cstring_view for kRunAsNode * refactor: use inline constexpr string_view for kPDF*PluginName * refactor: use base::FilePath::FromASCII() since "internal-pdf-viewer" is ascii * chore: remove unused shell/common/electron_constants.cc * fixup! refactor: IsEnvSet now takes a base::cstring_view
This commit is contained in:
parent
cc3359f126
commit
b3c2e83243
14 changed files with 41 additions and 59 deletions
|
@ -21,6 +21,7 @@
|
|||
#include "base/i18n/icu_util.h"
|
||||
#include "base/memory/raw_ptr_exclusion.h"
|
||||
#include "base/process/launch.h"
|
||||
#include "base/strings/cstring_view.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/win/dark_mode_support.h"
|
||||
#include "chrome/app/exit_code_watcher_win.h"
|
||||
|
@ -45,9 +46,9 @@ namespace {
|
|||
const char kUserDataDir[] = "user-data-dir";
|
||||
const char kProcessType[] = "type";
|
||||
|
||||
bool IsEnvSet(const char* name) {
|
||||
size_t required_size;
|
||||
getenv_s(&required_size, nullptr, 0, name);
|
||||
[[nodiscard]] bool IsEnvSet(const base::cstring_view name) {
|
||||
size_t required_size = 0;
|
||||
getenv_s(&required_size, nullptr, 0, name.c_str());
|
||||
return required_size != 0;
|
||||
}
|
||||
|
||||
|
@ -139,7 +140,7 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
|
|||
|
||||
#ifdef _DEBUG
|
||||
// Don't display assert dialog boxes in CI test runs
|
||||
static const char kCI[] = "CI";
|
||||
static constexpr base::cstring_view kCI = "CI";
|
||||
if (IsEnvSet(kCI)) {
|
||||
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
|
||||
_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue