Remove usage of base::make_span(): content/
Replace with span() CTAD use, or more targeted helpers. Bug: 341907909 Change-Id: I5c40ce02387df62d9c9769227271a3f6ef637a7a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6060230 Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org> Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org> Auto-Submit: Peter Kasting <pkasting@chromium.org> Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com> Cr-Commit-Position: refs/heads/main@{#1390215}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
2ebcecf303
commit
e263daabd1
content
common
android
service_worker
public
renderer
services
auction_worklet
shell
browser
test
web_test
@ -143,7 +143,7 @@ GinJavaBridgeValue::GinJavaBridgeValue(const base::Value* value)
|
||||
std::unique_ptr<base::Value> GinJavaBridgeValue::SerializeToBinaryValue() {
|
||||
const auto* data = static_cast<const uint8_t*>(pickle_.data());
|
||||
return base::Value::ToUniquePtrValue(
|
||||
base::Value(base::make_span(data, pickle_.size())));
|
||||
base::Value(base::span(data, pickle_.size())));
|
||||
}
|
||||
|
||||
} // namespace content
|
||||
|
@ -96,7 +96,7 @@ TEST_F(GinJavaBridgeValueTest, BrokenValues) {
|
||||
GinJavaBridgeValue::ContainsGinJavaBridgeValue(non_binary.get()));
|
||||
|
||||
const char dummy_data[] = "\000\001\002\003\004\005\006\007\010\011\012\013";
|
||||
base::Value broken_binary(base::as_bytes(base::make_span(dummy_data)));
|
||||
base::Value broken_binary(base::byte_span_with_nul_from_cstring(dummy_data));
|
||||
EXPECT_FALSE(GinJavaBridgeValue::ContainsGinJavaBridgeValue(&broken_binary));
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,8 @@ TEST(RaceNetworkRequestWriteBufferManagerTest, WriteData) {
|
||||
EXPECT_TRUE(buffer_manager.is_data_pipe_created());
|
||||
|
||||
const char expected_data[] = "abcde";
|
||||
base::span<const char> read_buffer = base::make_span(expected_data);
|
||||
base::span<const char> read_buffer =
|
||||
base::span_with_nul_from_cstring(expected_data);
|
||||
EXPECT_EQ(buffer_manager.BeginWriteData(), MOJO_RESULT_OK);
|
||||
size_t wirtten_num_bytes =
|
||||
buffer_manager.CopyAndCompleteWriteData(read_buffer);
|
||||
@ -48,7 +49,8 @@ TEST(RaceNetworkRequestWriteBufferManagerTest, WatchDataPipe) {
|
||||
buffer_manager.ArmOrNotify();
|
||||
run_loop.Run();
|
||||
const char expected_data[] = "abcde";
|
||||
base::span<const char> read_buffer = base::make_span(expected_data);
|
||||
base::span<const char> read_buffer =
|
||||
base::span_with_nul_from_cstring(expected_data);
|
||||
EXPECT_EQ(buffer_manager.BeginWriteData(), MOJO_RESULT_OK);
|
||||
size_t wirtten_num_bytes =
|
||||
buffer_manager.CopyAndCompleteWriteData(read_buffer);
|
||||
|
@ -3782,8 +3782,7 @@ DevToolsInspectorLogWatcher::DevToolsInspectorLogWatcher(
|
||||
host_->AttachClient(this);
|
||||
|
||||
host_->DispatchProtocolMessage(
|
||||
this, base::as_bytes(
|
||||
base::make_span(kEnableLogMessage, strlen(kEnableLogMessage))));
|
||||
this, base::byte_span_from_cstring(kEnableLogMessage));
|
||||
|
||||
run_loop_enable_log_.Run();
|
||||
}
|
||||
@ -3832,8 +3831,7 @@ void DevToolsInspectorLogWatcher::AgentHostClosed(DevToolsAgentHost* host) {}
|
||||
|
||||
void DevToolsInspectorLogWatcher::FlushAndStopWatching() {
|
||||
host_->DispatchProtocolMessage(
|
||||
this, base::as_bytes(base::make_span(kDisableLogMessage,
|
||||
strlen(kDisableLogMessage))));
|
||||
this, base::byte_span_from_cstring(kDisableLogMessage));
|
||||
run_loop_disable_log_.Run();
|
||||
}
|
||||
|
||||
|
@ -59,8 +59,7 @@ void ScopedPageFocusOverride::SetFocusEmulationEnabled(bool enabled) {
|
||||
|
||||
std::string json_command;
|
||||
base::JSONWriter::Write(command, &json_command);
|
||||
agent_host_->DispatchProtocolMessage(
|
||||
this, base::as_bytes(base::make_span(json_command)));
|
||||
agent_host_->DispatchProtocolMessage(this, base::as_byte_span(json_command));
|
||||
|
||||
base::RunLoop run_loop;
|
||||
EXPECT_FALSE(run_loop_quit_closure_);
|
||||
|
@ -47,8 +47,7 @@ const base::Value::Dict* TestDevToolsProtocolClient::SendSessionCommand(
|
||||
|
||||
std::string json_command;
|
||||
base::JSONWriter::Write(base::Value(std::move(command)), &json_command);
|
||||
agent_host_->DispatchProtocolMessage(
|
||||
this, base::as_bytes(base::make_span(json_command)));
|
||||
agent_host_->DispatchProtocolMessage(this, base::as_byte_span(json_command));
|
||||
// Some messages are dispatched synchronously.
|
||||
// Only run loop if we are not finished yet.
|
||||
if (in_dispatch_ && wait)
|
||||
|
@ -314,14 +314,14 @@ void AppendTouchEvent(const WebInputEvent& event,
|
||||
}
|
||||
|
||||
SetPPTouchPoints(
|
||||
base::make_span(touch_event.touches).first(touch_event.touches_length),
|
||||
ACTIVE, &result.touches);
|
||||
base::span(touch_event.touches).first(touch_event.touches_length), ACTIVE,
|
||||
&result.touches);
|
||||
SetPPTouchPoints(
|
||||
base::make_span(touch_event.touches).first(touch_event.touches_length),
|
||||
base::span(touch_event.touches).first(touch_event.touches_length),
|
||||
CHANGED, &result.changed_touches);
|
||||
SetPPTouchPoints(
|
||||
base::make_span(touch_event.touches).first(touch_event.touches_length),
|
||||
ALL, &result.target_touches);
|
||||
base::span(touch_event.touches).first(touch_event.touches_length), ALL,
|
||||
&result.target_touches);
|
||||
|
||||
result_events->push_back(result);
|
||||
}
|
||||
|
@ -514,7 +514,7 @@ std::unique_ptr<base::Value> V8ValueConverterImpl::FromV8ArrayBuffer(
|
||||
const auto* data = static_cast<const uint8_t*>(array_buffer->Data());
|
||||
const size_t byte_length = array_buffer->ByteLength();
|
||||
return base::Value::ToUniquePtrValue(
|
||||
base::Value(base::make_span(data, byte_length)));
|
||||
base::Value(base::span(data, byte_length)));
|
||||
}
|
||||
if (val->IsArrayBufferView()) {
|
||||
v8::Local<v8::ArrayBufferView> view = val.As<v8::ArrayBufferView>();
|
||||
|
@ -1259,8 +1259,7 @@ TEST_F(V8ValueConverterImplTest, StrategyBypass) {
|
||||
std::unique_ptr<base::Value> binary_value(
|
||||
converter.FromV8Value(array_buffer, context));
|
||||
ASSERT_TRUE(binary_value);
|
||||
base::Value reference_binary_value(
|
||||
base::as_bytes(base::make_span(kExampleData)));
|
||||
base::Value reference_binary_value(base::as_byte_span(kExampleData));
|
||||
EXPECT_EQ(reference_binary_value, *binary_value);
|
||||
|
||||
v8::Local<v8::ArrayBufferView> array_buffer_view(
|
||||
|
@ -115,8 +115,7 @@ std::string CreateKVv2RequestBody(std::string_view cbor_request_body) {
|
||||
size_t request_body_size = size_with_padding - kOhttpHeaderSize;
|
||||
request_body.resize(request_body_size, 0x00);
|
||||
|
||||
base::SpanWriter writer(
|
||||
base::as_writable_bytes(base::make_span(request_body)));
|
||||
base::SpanWriter writer(base::as_writable_byte_span(request_body));
|
||||
|
||||
// Add framing header. First byte includes version and compression format.
|
||||
// Always set first byte to 0x00 because request body is uncompressed.
|
||||
@ -125,7 +124,7 @@ std::string CreateKVv2RequestBody(std::string_view cbor_request_body) {
|
||||
base::checked_cast<uint32_t>(cbor_request_body.size()));
|
||||
|
||||
// Add CBOR string.
|
||||
writer.Write(base::as_bytes(base::make_span(cbor_request_body)));
|
||||
writer.Write(base::as_byte_span(cbor_request_body));
|
||||
|
||||
DCHECK_EQ(writer.num_written(), size_before_padding - kOhttpHeaderSize);
|
||||
return request_body;
|
||||
@ -140,11 +139,10 @@ std::string CreateKVv2ResponseBody(std::string_view cbor_response_body,
|
||||
}
|
||||
|
||||
std::string response_body(5 + cbor_response_body.size() + padding_length, 0);
|
||||
base::SpanWriter writer(
|
||||
base::as_writable_bytes(base::make_span(response_body)));
|
||||
base::SpanWriter writer(base::as_writable_byte_span(response_body));
|
||||
writer.WriteU8BigEndian(compression_scheme);
|
||||
writer.WriteU32BigEndian(*advertised_cbor_length);
|
||||
writer.Write(base::as_bytes(base::make_span(cbor_response_body)));
|
||||
writer.Write(base::as_byte_span(cbor_response_body));
|
||||
return response_body;
|
||||
}
|
||||
|
||||
|
@ -351,11 +351,10 @@ class TrustedKVv2SignalsEmbeddedTest : public testing::Test {
|
||||
size_t response_body_size = desired_size - kOhttpHeaderSize;
|
||||
response_body.resize(response_body_size, 0x00);
|
||||
|
||||
base::SpanWriter writer(
|
||||
base::as_writable_bytes(base::make_span(response_body)));
|
||||
base::SpanWriter writer(base::as_writable_byte_span(response_body));
|
||||
writer.WriteU8BigEndian(0x00);
|
||||
writer.WriteU32BigEndian(hex_bytes.size());
|
||||
writer.Write(base::as_bytes(base::make_span(hex_bytes)));
|
||||
writer.Write(base::as_byte_span(hex_bytes));
|
||||
|
||||
return response_body;
|
||||
}
|
||||
|
@ -93,8 +93,7 @@ quiche::ObliviousHttpRequest CreateOHttpRequest(
|
||||
size_t request_body_size = desired_size - kOhttpHeaderSize;
|
||||
request_body.resize(request_body_size, 0x00);
|
||||
|
||||
base::SpanWriter writer(
|
||||
base::as_writable_bytes(base::make_span(request_body)));
|
||||
base::SpanWriter writer(base::as_writable_byte_span(request_body));
|
||||
|
||||
// TODO(crbug.com/337917489): Add encryption here for compression scheme, CBOR
|
||||
// string length and CBOR string later.
|
||||
@ -106,7 +105,7 @@ quiche::ObliviousHttpRequest CreateOHttpRequest(
|
||||
base::checked_cast<uint32_t>(maybe_cbor_bytes->size()));
|
||||
|
||||
// Add CBOR string.
|
||||
writer.Write(base::as_bytes(base::make_span(*maybe_cbor_bytes)));
|
||||
writer.Write(base::as_byte_span(*maybe_cbor_bytes));
|
||||
|
||||
// Add encryption for request body.
|
||||
auto maybe_key_config = quiche::ObliviousHttpHeaderKeyConfig::Create(
|
||||
|
@ -251,11 +251,10 @@ std::string BuildResponseBody(const std::string& hex_string,
|
||||
size_t response_body_size = desired_size - kOhttpHeaderSize;
|
||||
response_body.resize(response_body_size, 0x00);
|
||||
|
||||
base::SpanWriter writer(
|
||||
base::as_writable_bytes(base::make_span(response_body)));
|
||||
base::SpanWriter writer(base::as_writable_byte_span(response_body));
|
||||
writer.WriteU8BigEndian(compress_scheme);
|
||||
writer.WriteU32BigEndian(hex_bytes.size());
|
||||
writer.Write(base::as_bytes(base::make_span(hex_bytes)));
|
||||
writer.Write(base::as_byte_span(hex_bytes));
|
||||
|
||||
return response_body;
|
||||
}
|
||||
@ -2582,7 +2581,7 @@ TEST_F(TrustedSignalsKVv2ResponseParserTest, NonCborData) {
|
||||
TrustedSignalsKVv2ResponseParser::ParseEntireCompressionGroup(
|
||||
helper_.get(), signals_type,
|
||||
mojom::TrustedSignalsCompressionScheme::kNone,
|
||||
base::as_bytes(base::make_span("Not CBOR")));
|
||||
base::byte_span_with_nul_from_cstring("Not CBOR"));
|
||||
EXPECT_THAT(result_or_error, IsError("Failed to parse content as CBOR."));
|
||||
}
|
||||
}
|
||||
@ -2679,7 +2678,7 @@ TEST_F(TrustedSignalsKVv2ResponseParserTest,
|
||||
// gzip code unconditionally allocates memory based on the last 4
|
||||
// bytes of the response, which can be quite large. End this string
|
||||
// with 4 character 01's to avoid allocating too much memory.
|
||||
base::as_bytes(base::make_span("Not gzip.\x1\x1\x1\x1")));
|
||||
base::byte_span_with_nul_from_cstring("Not gzip.\x1\x1\x1\x1"));
|
||||
ASSERT_THAT(result_or_error,
|
||||
IsError("Failed to decompress content string with Gzip."));
|
||||
}
|
||||
|
@ -262,8 +262,8 @@ void ShellDevToolsBindings::HandleMessageFromDevToolsFrontend(
|
||||
const std::string* protocol_message = params[0].GetIfString();
|
||||
if (!agent_host_ || !protocol_message)
|
||||
return;
|
||||
agent_host_->DispatchProtocolMessage(
|
||||
this, base::as_bytes(base::make_span(*protocol_message)));
|
||||
agent_host_->DispatchProtocolMessage(this,
|
||||
base::as_byte_span(*protocol_message));
|
||||
} else if (*method == "loadCompleted") {
|
||||
CallClientFunction("DevToolsAPI", "setUseSoftMenu", base::Value(true));
|
||||
} else if (*method == "loadNetworkResource" && params.size() == 3) {
|
||||
|
@ -35,9 +35,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
return 0;
|
||||
auto before_fallback_url_bytes =
|
||||
CopyIntoSeparateBufferToSurfaceOutOfBoundAccess(
|
||||
base::make_span(data, BeforeFallbackUrl::kEncodedSizeInBytes));
|
||||
base::span(data, BeforeFallbackUrl::kEncodedSizeInBytes));
|
||||
auto before_fallback_url = BeforeFallbackUrl::Parse(
|
||||
base::make_span(before_fallback_url_bytes), nullptr /* devtools_proxy */);
|
||||
base::span(before_fallback_url_bytes), nullptr /* devtools_proxy */);
|
||||
|
||||
data += BeforeFallbackUrl::kEncodedSizeInBytes;
|
||||
size -= BeforeFallbackUrl::kEncodedSizeInBytes;
|
||||
@ -49,9 +49,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
|
||||
auto fallback_url_and_after_bytes =
|
||||
CopyIntoSeparateBufferToSurfaceOutOfBoundAccess(
|
||||
base::make_span(data, fallback_url_and_after_length));
|
||||
base::span(data, fallback_url_and_after_length));
|
||||
auto fallback_url_and_after = FallbackUrlAndAfter::Parse(
|
||||
base::make_span(fallback_url_and_after_bytes), before_fallback_url,
|
||||
base::span(fallback_url_and_after_bytes), before_fallback_url,
|
||||
nullptr /* devtools_proxy */);
|
||||
if (!fallback_url_and_after.is_valid())
|
||||
return 0;
|
||||
@ -65,14 +65,13 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
data += signature_header_field.size();
|
||||
size -= signature_header_field.size();
|
||||
|
||||
auto cbor_header =
|
||||
CopyIntoSeparateBufferToSurfaceOutOfBoundAccess(base::make_span(
|
||||
data, std::min(size, fallback_url_and_after.cbor_header_length())));
|
||||
auto cbor_header = CopyIntoSeparateBufferToSurfaceOutOfBoundAccess(base::span(
|
||||
data, std::min(size, fallback_url_and_after.cbor_header_length())));
|
||||
|
||||
SignedExchangeEnvelope::Parse(
|
||||
SignedExchangeVersion::kB3, fallback_url_and_after.fallback_url(),
|
||||
signature_header_field, base::make_span(cbor_header),
|
||||
nullptr /* devtools_proxy */);
|
||||
SignedExchangeEnvelope::Parse(SignedExchangeVersion::kB3,
|
||||
fallback_url_and_after.fallback_url(),
|
||||
signature_header_field, base::span(cbor_header),
|
||||
nullptr /* devtools_proxy */);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -168,7 +168,7 @@ void DevToolsProtocolTestBindings::HandleMessageFromTest(
|
||||
WebTestControlHost::Get()->PrintMessageToStderr(
|
||||
"Protocol message: " + *protocol_message + "\n");
|
||||
agent_host_->DispatchProtocolMessage(
|
||||
this, base::as_bytes(base::make_span(*protocol_message)));
|
||||
this, base::as_byte_span(*protocol_message));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user