chore: migrate base::StringPiece to std::string_view (#40915)
* chore: migrate from base::StringPiece to std::string_view in keyboard_util.cc
* chore: migrate from base::StringPiece to std::string_view in error_thrower.cc
* chore: migrate from base::StringPiece to std::string_view in electron_api_web_contents.cc
* chore: migrate from base::StringPiece to std::string_view in gin_helper/dictionary.h
* chore: migrate from base::StringPiece to std::string_view in electron_api_url_loader.cc
* chore: phase out internal use of base:::StringPiece
`base::StringPiece` is being phased out upstream. Its code has been
removed upstream and it's just a typedef for `std::string_view`.
They haven't removed the typedef yet, so this PR tries to get ahead
of future breakage by migrating "internal" use (i.e. leaving alone the
places where the `base::StringPiece` name is coming from an upstream
method that we override).
Xref: https://bugs.chromium.org/p/chromium/issues/detail?id=691162
Xref: 4294483
Xref: https://docs.google.com/document/d/1d4RnD1uAE2t4iANR0nXy82ASIPGsPuw2mpO6v6T7JKs
This commit is contained in:
parent
892c9d78a3
commit
f36ceae024
45 changed files with 223 additions and 174 deletions
|
@ -5,6 +5,7 @@
|
|||
#include "shell/app/electron_content_client.h"
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
|
@ -106,12 +107,12 @@ bool IsWidevineAvailable(
|
|||
}
|
||||
#endif // BUILDFLAG(ENABLE_WIDEVINE)
|
||||
|
||||
void AppendDelimitedSwitchToVector(const base::StringPiece cmd_switch,
|
||||
void AppendDelimitedSwitchToVector(const std::string_view cmd_switch,
|
||||
std::vector<std::string>* append_me) {
|
||||
auto* command_line = base::CommandLine::ForCurrentProcess();
|
||||
auto switch_value = command_line->GetSwitchValueASCII(cmd_switch);
|
||||
if (!switch_value.empty()) {
|
||||
constexpr base::StringPiece delimiter(",", 1);
|
||||
constexpr std::string_view delimiter{",", 1};
|
||||
auto tokens =
|
||||
base::SplitString(switch_value, delimiter, base::TRIM_WHITESPACE,
|
||||
base::SPLIT_WANT_NONEMPTY);
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
#include "base/apple/bundle_locations.h"
|
||||
|
@ -80,9 +81,9 @@ namespace {
|
|||
|
||||
const char kRelauncherProcess[] = "relauncher";
|
||||
|
||||
constexpr base::StringPiece kElectronDisableSandbox("ELECTRON_DISABLE_SANDBOX");
|
||||
constexpr base::StringPiece kElectronEnableStackDumping(
|
||||
"ELECTRON_ENABLE_STACK_DUMPING");
|
||||
constexpr std::string_view kElectronDisableSandbox{"ELECTRON_DISABLE_SANDBOX"};
|
||||
constexpr std::string_view kElectronEnableStackDumping{
|
||||
"ELECTRON_ENABLE_STACK_DUMPING"};
|
||||
|
||||
// Returns true if this subprocess type needs the ResourceBundle initialized
|
||||
// and resources loaded.
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
|
@ -60,7 +61,7 @@ namespace {
|
|||
// See https://nodejs.org/api/cli.html#cli_options
|
||||
void ExitIfContainsDisallowedFlags(const std::vector<std::string>& argv) {
|
||||
// Options that are unilaterally disallowed.
|
||||
static constexpr auto disallowed = base::MakeFixedFlatSet<base::StringPiece>({
|
||||
static constexpr auto disallowed = base::MakeFixedFlatSet<std::string_view>({
|
||||
"--enable-fips",
|
||||
"--force-fips",
|
||||
"--openssl-config",
|
||||
|
@ -69,7 +70,7 @@ void ExitIfContainsDisallowedFlags(const std::vector<std::string>& argv) {
|
|||
});
|
||||
|
||||
for (const auto& arg : argv) {
|
||||
const auto key = base::StringPiece(arg).substr(0, arg.find('='));
|
||||
const auto key = std::string_view{arg}.substr(0, arg.find('='));
|
||||
if (disallowed.contains(key)) {
|
||||
LOG(ERROR) << "The Node.js cli flag " << key
|
||||
<< " is not supported in Electron";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue