0

Convert base::StringPiece to std::string_view in //components 3/5

The changes of this CL are made using the following script.
Script: https://issues.chromium.org/issues/40506050#comment343

Bug: 40506050
Change-Id: I7b21541a0723d312206c786d3af570f552ceef4e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5498922
Auto-Submit: Helmut Januschka <helmut@januschka.com>
Commit-Queue: Helmut Januschka <helmut@januschka.com>
Reviewed-by: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1295637}
This commit is contained in:
Helmut Januschka
2024-05-02 18:42:28 +00:00
committed by Chromium LUCI CQ
parent 68ba09c5a4
commit 3ae90009a0
98 changed files with 441 additions and 387 deletions
components
prefs
printing
safe_browsing
safe_search_api
search_engines
search_provider_logos
segmentation_platform
sessions
shared_highlighting
signin
speech

@ -5,8 +5,10 @@
#include "components/sessions/core/command_storage_backend.h"
#include <stdint.h>
#include <algorithm>
#include <limits>
#include <string_view>
#include <utility>
#include "base/feature_list.h"
@ -333,8 +335,8 @@ SessionFileReader::CreateCommandFromEncrypted(const char* data,
memset(nonce, 0, kNonceLength);
memcpy(nonce, &command_counter_, sizeof(command_counter_));
std::string plain_text;
if (!aead_->Open(base::StringPiece(data, length),
base::StringPiece(nonce, kNonceLength), base::StringPiece(),
if (!aead_->Open(std::string_view(data, length),
std::string_view(nonce, kNonceLength), std::string_view(),
&plain_text)) {
DVLOG(1) << "SessionFileReader::ReadCommand, decryption failed";
return nullptr;
@ -821,8 +823,8 @@ bool CommandStorageBackend::AppendEncryptedCommandToFile(
command_size);
std::string cipher_text;
aead_->Seal(base::StringPiece(&command_and_id.front(), command_and_id.size()),
base::StringPiece(nonce, kNonceLength), base::StringPiece(),
aead_->Seal(std::string_view(&command_and_id.front(), command_and_id.size()),
std::string_view(nonce, kNonceLength), std::string_view(),
&cipher_text);
DCHECK_LE(cipher_text.size(), std::numeric_limits<size_type>::max());
const size_type command_and_id_size =

@ -9,8 +9,8 @@
#include <stdint.h>
#include <string>
#include <string_view>
#include "base/strings/string_piece.h"
#include "components/sessions/core/sessions_export.h"
namespace base {
@ -52,8 +52,8 @@ class SESSIONS_EXPORT SessionCommand {
// The contents of the command.
char* contents() { return const_cast<char*>(contents_.c_str()); }
const char* contents() const { return contents_.c_str(); }
base::StringPiece contents_as_string_piece() const {
return base::StringPiece(contents_);
std::string_view contents_as_string_piece() const {
return std::string_view(contents_);
}
// Identifier for the command.
id_type id() const { return id_; }