[base] Remove base::StringPiece::as_string() usages
Bug: 1049498 Change-Id: Ia6fc9f76b45e755fbe67171e6c3513c95932c00f Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2601364 Commit-Queue: Peter Kasting <pkasting@chromium.org> Owners-Override: Peter Kasting <pkasting@chromium.org> Owners-Override: Gabriel Charette <gab@chromium.org> Reviewed-by: Gabriel Charette <gab@chromium.org> Cr-Commit-Position: refs/heads/master@{#877499}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
d7058b5c43
commit
846e1896b7
android_webview/browser/safe_browsing
chromecast/bindings
crypto
device
google_apis
gpu
headless/lib/browser
printing
sql/recover_module
third_party
@ -11,6 +11,7 @@
|
||||
#include "base/bind.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/sequenced_task_runner.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/strings/string_split.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/task_runner_util.h"
|
||||
@ -67,7 +68,7 @@ void InsertRuleToTrie(const std::vector<base::StringPiece>& components,
|
||||
for (auto hostcomp = components.rbegin(); hostcomp != components.rend();
|
||||
++hostcomp) {
|
||||
DCHECK(!node->match_prefix);
|
||||
std::string component = hostcomp->as_string();
|
||||
std::string component(*hostcomp);
|
||||
auto child_node = node->children.find(component);
|
||||
if (child_node == node->children.end()) {
|
||||
std::unique_ptr<TrieNode> temp = std::make_unique<TrieNode>();
|
||||
@ -117,7 +118,7 @@ bool AddRuleToAllowlist(base::StringPiece rule, TrieNode* root) {
|
||||
started_with_dot = true;
|
||||
}
|
||||
// With the dot removed |rule| should look like a hostname.
|
||||
GURL test_url("http://" + rule.as_string());
|
||||
GURL test_url("http://" + std::string(rule));
|
||||
if (!test_url.is_valid()) {
|
||||
return false;
|
||||
}
|
||||
@ -162,7 +163,7 @@ bool IsAllowed(const GURL& url, const TrieNode* node) {
|
||||
if (node->match_prefix) {
|
||||
return true;
|
||||
}
|
||||
auto child_node = node->children.find(component->as_string());
|
||||
auto child_node = node->children.find(std::string(*component));
|
||||
if (child_node == node->children.end()) {
|
||||
return false;
|
||||
} else {
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "base/check.h"
|
||||
#include "base/fuchsia/fuchsia_logging.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "components/cast/message_port/message_port_fuchsia.h"
|
||||
#include "fuchsia/base/mem_buffer_util.h"
|
||||
#include "fuchsia/base/message_port.h"
|
||||
@ -22,7 +23,7 @@ BindingsManagerFuchsia::~BindingsManagerFuchsia() = default;
|
||||
|
||||
void BindingsManagerFuchsia::AddBinding(base::StringPiece binding_name,
|
||||
base::StringPiece binding_script) {
|
||||
bindings_[binding_name.as_string()] =
|
||||
bindings_[std::string(binding_name)] =
|
||||
cr_fuchsia::MemBufferFromString(binding_script, "cast-binding-script");
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <algorithm>
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "crypto/random.h"
|
||||
#include "crypto/secure_util.h"
|
||||
#include "third_party/boringssl/src/include/openssl/bn.h"
|
||||
@ -276,11 +277,11 @@ P224EncryptedKeyExchange::Result P224EncryptedKeyExchange::ProcessMessage(
|
||||
|
||||
std::string client_masked_dh, server_masked_dh;
|
||||
if (is_server_) {
|
||||
client_masked_dh = message.as_string();
|
||||
client_masked_dh = std::string(message);
|
||||
server_masked_dh = next_message_;
|
||||
} else {
|
||||
client_masked_dh = next_message_;
|
||||
server_masked_dh = message.as_string();
|
||||
server_masked_dh = std::string(message);
|
||||
}
|
||||
|
||||
// Now we calculate the hashes that each side will use to prove to the other
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "base/check.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "components/cbor/reader.h"
|
||||
#include "components/cbor/values.h"
|
||||
#include "components/cbor/writer.h"
|
||||
@ -62,10 +63,10 @@ class TestNetworkContext : public network::TestNetworkContext {
|
||||
static const char kContactPrefix[] = "/cable/contact/";
|
||||
if (path.find(kNewPrefix) == 0) {
|
||||
path.remove_prefix(sizeof(kNewPrefix) - 1);
|
||||
CHECK(!base::Contains(connections_, path.as_string()));
|
||||
connections_.emplace(path.as_string(), std::make_unique<Connection>(
|
||||
Connection::Type::NEW,
|
||||
std::move(handshake_client)));
|
||||
CHECK(!base::Contains(connections_, std::string(path)));
|
||||
connections_.emplace(std::string(path), std::make_unique<Connection>(
|
||||
Connection::Type::NEW,
|
||||
std::move(handshake_client)));
|
||||
} else if (path.find(kConnectPrefix) == 0) {
|
||||
path.remove_prefix(sizeof(kConnectPrefix) - 1);
|
||||
// The first part of |path| will be a hex-encoded routing ID followed by a
|
||||
@ -74,7 +75,7 @@ class TestNetworkContext : public network::TestNetworkContext {
|
||||
CHECK_GE(path.size(), kRoutingIdComponentSize);
|
||||
path.remove_prefix(kRoutingIdComponentSize);
|
||||
|
||||
const auto it = connections_.find(path.as_string());
|
||||
const auto it = connections_.find(std::string(path));
|
||||
CHECK(it != connections_.end()) << "Unknown tunnel requested";
|
||||
it->second->set_peer(std::make_unique<Connection>(
|
||||
Connection::Type::CONNECT, std::move(handshake_client)));
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "base/bind.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/threading/scoped_blocking_call.h"
|
||||
|
||||
namespace device {
|
||||
@ -16,9 +17,9 @@ namespace device {
|
||||
UdevWatcher::Filter::Filter(base::StringPiece subsystem_in,
|
||||
base::StringPiece devtype_in) {
|
||||
if (!subsystem_in.empty())
|
||||
subsystem_ = subsystem_in.as_string();
|
||||
subsystem_ = std::string(subsystem_in);
|
||||
if (!devtype_in.empty())
|
||||
devtype_ = devtype_in.as_string();
|
||||
devtype_ = std::string(devtype_in);
|
||||
}
|
||||
|
||||
UdevWatcher::Filter::Filter(const Filter&) = default;
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "base/macros.h"
|
||||
#include "base/sequenced_task_runner.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/task_runner_util.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
@ -455,7 +456,7 @@ void UrlFetchRequestBase::OnDataReceived(base::StringPiece string_piece,
|
||||
base::PostTaskAndReplyWithResult(
|
||||
blocking_task_runner(), FROM_HERE,
|
||||
base::BindOnce(&UrlFetchRequestBase::WriteFileData,
|
||||
string_piece.as_string(), download_data_ptr),
|
||||
std::string(string_piece), download_data_ptr),
|
||||
base::BindOnce(&UrlFetchRequestBase::OnWriteComplete,
|
||||
weak_ptr_factory_.GetWeakPtr(),
|
||||
std::move(download_data_), std::move(resume)));
|
||||
|
@ -92,7 +92,7 @@ void GetSwitchValueWithDefault(base::StringPiece switch_value,
|
||||
if (command_line->HasSwitch(switch_value)) {
|
||||
*output_value = command_line->GetSwitchValueASCII(switch_value);
|
||||
} else {
|
||||
*output_value = default_value.as_string();
|
||||
*output_value = std::string(default_value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <memory>
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/trace_event/trace_event.h"
|
||||
#include "gpu/command_buffer/common/cmd_buffer_common.h"
|
||||
#include "gpu/command_buffer/common/command_buffer_shared.h"
|
||||
@ -44,7 +45,7 @@ void CommandBufferService::Flush(int32_t put_offset,
|
||||
}
|
||||
|
||||
TRACE_EVENT1("gpu", "CommandBufferService:PutChanged", "handler",
|
||||
handler->GetLogPrefix().as_string());
|
||||
std::string(handler->GetLogPrefix()));
|
||||
|
||||
put_offset_ = put_offset;
|
||||
|
||||
|
@ -255,7 +255,7 @@ bool CollectBasicGraphicsInfo(const base::CommandLine* command_line,
|
||||
// Also declare the driver_vendor to be <software GL> to be able to
|
||||
// specify exceptions based on driver_vendor==<software GL> for some
|
||||
// blocklist rules.
|
||||
gpu_info->gpu.driver_vendor = software_gl_impl_name.as_string();
|
||||
gpu_info->gpu.driver_vendor = std::string(software_gl_impl_name);
|
||||
|
||||
return true;
|
||||
} else if ((implementation == gl::GetSoftwareGLImplementation()) ||
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "base/i18n/rtl.h"
|
||||
#include "base/path_service.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/strings/string_split.h"
|
||||
#include "build/build_config.h"
|
||||
#include "components/embedder_support/switches.h"
|
||||
@ -250,7 +251,7 @@ void HeadlessContentBrowserClient::AppendExtraCommandLineSwitches(
|
||||
base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
|
||||
if (!languages.empty()) {
|
||||
command_line->AppendSwitchASCII(::switches::kLang,
|
||||
languages[0].as_string());
|
||||
std::string(languages[0]));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ gfx::Size GetDefaultPaperSizeFromLocaleMicrons(base::StringPiece locale) {
|
||||
int32_t width = 0;
|
||||
int32_t height = 0;
|
||||
UErrorCode error = U_ZERO_ERROR;
|
||||
ulocdata_getPaperSize(locale.as_string().c_str(), &height, &width, &error);
|
||||
ulocdata_getPaperSize(std::string(locale).c_str(), &height, &width, &error);
|
||||
if (error > U_ZERO_ERROR) {
|
||||
// If the call failed, assume Letter paper size.
|
||||
LOG(WARNING) << "ulocdata_getPaperSize failed, using ISO A4 Paper, error: "
|
||||
|
@ -192,7 +192,7 @@ RecoveredColumnSpec ParseColumnSpec(const char* sqlite_arg) {
|
||||
result.is_non_null = true;
|
||||
}
|
||||
|
||||
result.name = column_name.as_string();
|
||||
result.name = std::string(column_name);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -212,7 +212,7 @@ TargetTableSpec ParseTableSpec(const char* sqlite_arg) {
|
||||
|
||||
base::StringPiece db_name = sql.substr(0, separator_pos);
|
||||
base::StringPiece table_name = sql.substr(separator_pos + 1);
|
||||
return TargetTableSpec{db_name.as_string(), table_name.as_string()};
|
||||
return TargetTableSpec{std::string(db_name), std::string(table_name)};
|
||||
}
|
||||
|
||||
} // namespace recover
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "package.h"
|
||||
|
||||
@ -92,7 +93,7 @@ int ToolSupport::Wmain(int argc, wchar_t* argv[], int (*entry)(int, char* [])) {
|
||||
base::FilePath::StringType ToolSupport::CommandLineArgumentToFilePathStringType(
|
||||
const base::StringPiece& path) {
|
||||
#if defined(OS_POSIX)
|
||||
return path.as_string();
|
||||
return std::string(path);
|
||||
#elif defined(OS_WIN)
|
||||
return base::UTF8ToWide(path);
|
||||
#endif // OS_POSIX
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "base/path_service.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/stl_util.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/test/task_environment.h"
|
||||
@ -510,12 +511,12 @@ TEST_F(ZipReaderTest, ExtractCurrentEntryToString) {
|
||||
if (i > 0) {
|
||||
// Exact byte read limit: must pass.
|
||||
EXPECT_TRUE(reader.ExtractCurrentEntryToString(i, &contents));
|
||||
EXPECT_EQ(base::StringPiece("0123456", i).as_string(), contents);
|
||||
EXPECT_EQ(std::string(base::StringPiece("0123456", i)), contents);
|
||||
}
|
||||
|
||||
// More than necessary byte read limit: must pass.
|
||||
EXPECT_TRUE(reader.ExtractCurrentEntryToString(16, &contents));
|
||||
EXPECT_EQ(base::StringPiece("0123456", i).as_string(), contents);
|
||||
EXPECT_EQ(std::string(base::StringPiece("0123456", i)), contents);
|
||||
}
|
||||
reader.Close();
|
||||
}
|
||||
|
Reference in New Issue
Block a user