0

Pass size_t to span functions: content/

In preparation for upgrading various span args from size_t to
StrictNumeric<size_t>, this fixes type mismatches that would cause
compile errors with that change.

Bug: none
Change-Id: I9614f231bcae99159dfe7e65126b3a244e317452
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6020622
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Shunya Shishido <sisidovski@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@{#1383027}
This commit is contained in:
Peter Kasting
2024-11-14 16:23:52 +00:00
committed by Chromium LUCI CQ
parent b2390f528e
commit 14a5968c17
4 changed files with 9 additions and 9 deletions

@ -29,7 +29,6 @@ class ServiceWorkerInstalledScriptReader::MetaDataSender {
MetaDataSender(scoped_refptr<net::IOBufferWithSize> meta_data,
mojo::ScopedDataPipeProducerHandle handle)
: meta_data_(std::move(meta_data)),
bytes_sent_(0),
handle_(std::move(handle)),
watcher_(FROM_HERE,
mojo::SimpleWatcher::ArmingPolicy::AUTOMATIC,
@ -76,8 +75,9 @@ class ServiceWorkerInstalledScriptReader::MetaDataSender {
"ServiceWorker",
"ServiceWorkerInstalledScriptReader::MetaDataSender::OnWritable",
"meta_data size", meta_data_->size(), "new bytes_sent_", bytes_sent_);
if (meta_data_->size() == bytes_sent_)
if (static_cast<size_t>(meta_data_->size()) == bytes_sent_) {
OnCompleted(true);
}
}
void OnCompleted(bool success) {
@ -93,7 +93,7 @@ class ServiceWorkerInstalledScriptReader::MetaDataSender {
base::OnceCallback<void(bool /* success */)> callback_;
scoped_refptr<net::IOBufferWithSize> meta_data_;
int64_t bytes_sent_;
size_t bytes_sent_ = 0;
mojo::ScopedDataPipeProducerHandle handle_;
mojo::SimpleWatcher watcher_;

@ -283,8 +283,8 @@ void ServiceWorkerUpdatedScriptLoader::OnClientWritable(MojoResult) {
// Cap the buffer size up to |kReadBufferSize|. The remaining will be written
// next time.
base::span<const uint8_t> bytes_to_send = data_to_send_->span();
bytes_to_send = bytes_to_send.first(
std::min(bytes_to_send.size(), base::checked_cast<size_t>(data_length_)));
bytes_to_send =
bytes_to_send.first(std::min(bytes_to_send.size(), data_length_));
bytes_to_send = bytes_to_send.subspan(bytes_sent_to_client_);
bytes_to_send = bytes_to_send.first(
std::min<size_t>(bytes_to_send.size(), kReadBufferSize));
@ -325,7 +325,7 @@ int ServiceWorkerUpdatedScriptLoader::WillWriteData(
CHECK(client_producer_);
data_to_send_ = std::move(data);
data_length_ = length;
data_length_ = base::checked_cast<size_t>(length);
bytes_sent_to_client_ = 0;
write_observer_complete_callback_ = std::move(callback);
client_producer_watcher_.ArmOrNotify();

@ -227,10 +227,10 @@ class CONTENT_EXPORT ServiceWorkerUpdatedScriptLoader final
scoped_refptr<net::IOBuffer> data_to_send_;
// Length of |data_to_send_| in bytes.
int data_length_ = 0;
size_t data_length_ = 0;
// Length of data in |data_to_send_| already sent to |client_|.
int bytes_sent_to_client_ = 0;
size_t bytes_sent_to_client_ = 0;
// Run this to notify ServiceWorkerCacheWriter that the observer completed
// its work. net::OK means all |data_to_send_| has been sent to |client_|.

@ -99,6 +99,6 @@ base::span<const char> RaceNetworkRequestReadBufferManager::RemainingBuffer()
// base::span with the actual data size. IOBuffer::span() returns the span
// with the size of the whole buffer, even if data is partially consumed. So
// subspan it with the remaining data size.
return base::as_chars(buffer_->span()).subspan(0, buffer_->BytesRemaining());
return base::as_chars(buffer_->span()).subspan(0, BytesRemaining());
}
} // namespace content