From 95a9ff952c231eca2f04e7f444b2e1818b4f65a0 Mon Sep 17 00:00:00 2001 From: David Sanders Date: Thu, 1 Jul 2021 17:51:52 -0700 Subject: [PATCH] chore: cleanup usages of const char* (#29906) --- shell/app/electron_main.cc | 2 +- shell/app/electron_main_delegate.cc | 2 +- shell/browser/api/electron_api_protocol.cc | 2 +- shell/browser/api/electron_api_web_request.cc | 2 +- shell/browser/api/gpu_info_enumerator.h | 12 ++++++------ shell/common/gin_helper/trackable_object.cc | 2 +- shell/renderer/api/electron_api_context_bridge.cc | 9 ++++----- shell/renderer/api/electron_api_web_frame.cc | 6 +++--- 8 files changed, 18 insertions(+), 19 deletions(-) diff --git a/shell/app/electron_main.cc b/shell/app/electron_main.cc index d8cb6300f5..f72f42c420 100644 --- a/shell/app/electron_main.cc +++ b/shell/app/electron_main.cc @@ -116,7 +116,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 const char kCI[] = "CI"; if (IsEnvSet(kCI)) { _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR); diff --git a/shell/app/electron_main_delegate.cc b/shell/app/electron_main_delegate.cc index e19e9565ad..1c22e2f4fa 100644 --- a/shell/app/electron_main_delegate.cc +++ b/shell/app/electron_main_delegate.cc @@ -70,7 +70,7 @@ namespace electron { namespace { -const char* kRelauncherProcess = "relauncher"; +const char kRelauncherProcess[] = "relauncher"; constexpr base::StringPiece kElectronDisableSandbox("ELECTRON_DISABLE_SANDBOX"); constexpr base::StringPiece kElectronEnableStackDumping( diff --git a/shell/browser/api/electron_api_protocol.cc b/shell/browser/api/electron_api_protocol.cc index 70bbcd769a..cd396e9662 100644 --- a/shell/browser/api/electron_api_protocol.cc +++ b/shell/browser/api/electron_api_protocol.cc @@ -163,7 +163,7 @@ void RegisterSchemesAsPrivileged(gin_helper::ErrorThrower thrower, namespace { -const char* kBuiltinSchemes[] = { +const char* const kBuiltinSchemes[] = { "about", "file", "http", "https", "data", "filesystem", }; diff --git a/shell/browser/api/electron_api_web_request.cc b/shell/browser/api/electron_api_web_request.cc index 8dc4ed7a13..56845a6ced 100644 --- a/shell/browser/api/electron_api_web_request.cc +++ b/shell/browser/api/electron_api_web_request.cc @@ -84,7 +84,7 @@ namespace api { namespace { -const char* kUserDataKey = "WebRequest"; +const char kUserDataKey[] = "WebRequest"; // BrowserContext <=> WebRequest relationship. struct UserData : public base::SupportsUserData::Data { diff --git a/shell/browser/api/gpu_info_enumerator.h b/shell/browser/api/gpu_info_enumerator.h index b457e856e5..aa4db84867 100644 --- a/shell/browser/api/gpu_info_enumerator.h +++ b/shell/browser/api/gpu_info_enumerator.h @@ -17,15 +17,15 @@ namespace electron { // This class implements the enumerator for reading all the attributes in // GPUInfo into a dictionary. class GPUInfoEnumerator final : public gpu::GPUInfo::Enumerator { - const char* kGPUDeviceKey = "gpuDevice"; - const char* kVideoDecodeAcceleratorSupportedProfileKey = + const char* const kGPUDeviceKey = "gpuDevice"; + const char* const kVideoDecodeAcceleratorSupportedProfileKey = "videoDecodeAcceleratorSupportedProfile"; - const char* kVideoEncodeAcceleratorSupportedProfileKey = + const char* const kVideoEncodeAcceleratorSupportedProfileKey = "videoEncodeAcceleratorSupportedProfile"; - const char* kImageDecodeAcceleratorSupportedProfileKey = + const char* const kImageDecodeAcceleratorSupportedProfileKey = "imageDecodeAcceleratorSupportedProfile"; - const char* kAuxAttributesKey = "auxAttributes"; - const char* kOverlayInfo = "overlayInfo"; + const char* const kAuxAttributesKey = "auxAttributes"; + const char* const kOverlayInfo = "overlayInfo"; public: GPUInfoEnumerator(); diff --git a/shell/common/gin_helper/trackable_object.cc b/shell/common/gin_helper/trackable_object.cc index bc0b5c7d0a..1ea5bd51b4 100644 --- a/shell/common/gin_helper/trackable_object.cc +++ b/shell/common/gin_helper/trackable_object.cc @@ -15,7 +15,7 @@ namespace gin_helper { namespace { -const char* kTrackedObjectKey = "TrackedObjectKey"; +const char kTrackedObjectKey[] = "TrackedObjectKey"; class IDUserData : public base::SupportsUserData::Data { public: diff --git a/shell/renderer/api/electron_api_context_bridge.cc b/shell/renderer/api/electron_api_context_bridge.cc index b072e3cb01..0cc9928285 100644 --- a/shell/renderer/api/electron_api_context_bridge.cc +++ b/shell/renderer/api/electron_api_context_bridge.cc @@ -41,11 +41,10 @@ namespace api { namespace context_bridge { -const char* const kProxyFunctionPrivateKey = "electron_contextBridge_proxy_fn"; -const char* const kSupportsDynamicPropertiesPrivateKey = +const char kProxyFunctionPrivateKey[] = "electron_contextBridge_proxy_fn"; +const char kSupportsDynamicPropertiesPrivateKey[] = "electron_contextBridge_supportsDynamicProperties"; -const char* const kOriginalFunctionPrivateKey = - "electron_contextBridge_original_fn"; +const char kOriginalFunctionPrivateKey[] = "electron_contextBridge_original_fn"; } // namespace context_bridge @@ -439,7 +438,7 @@ void ProxyFunctionWrapper(const v8::FunctionCallbackInfo& info) { did_error = true; v8::Local exception = try_catch.Exception(); - const char* err_msg = + const char err_msg[] = "An unknown exception occurred in the isolated context, an error " "occurred but a valid exception was not thrown."; diff --git a/shell/renderer/api/electron_api_web_frame.cc b/shell/renderer/api/electron_api_web_frame.cc index d880b271a9..ad786c0f5d 100644 --- a/shell/renderer/api/electron_api_web_frame.cc +++ b/shell/renderer/api/electron_api_web_frame.cc @@ -211,7 +211,7 @@ class ScriptExecutionCallback : public blink::WebScriptExecutionCallback { promise_.Resolve(value); } } else { - const char* error_message = + const char error_message[] = "Script failed to execute, this normally means an error " "was thrown. Check the renderer console for the error."; if (!callback_.is_null()) { @@ -226,7 +226,7 @@ class ScriptExecutionCallback : public blink::WebScriptExecutionCallback { promise_.RejectWithErrorMessage(error_message); } } else { - const char* error_message = + const char error_message[] = "WebFrame was removed before script could run. This normally means " "the underlying frame was destroyed"; if (!callback_.is_null()) { @@ -705,7 +705,7 @@ class WebFrameRenderer : public gin::Wrappable, script.Get("startLine", &start_line); if (!script.Get("code", &code)) { - const char* error_message = "Invalid 'code'"; + const char error_message[] = "Invalid 'code'"; if (!completion_callback.is_null()) { std::move(completion_callback) .Run(v8::Undefined(isolate),