Attention needed from Sami Kyöstilä
Łukasz Anforowicz has uploaded the change for review![Open in Gerrit]()
Łukasz Anforowicz would like Sami Kyöstilä to review this change.
Commit message
`span`-ify `mojo/.../data_pipe.h`: Migrate `services/tracing`.
`span`-ification: `mojo::DataPipe[Consumer|Producer]Handle`: Migrating
callers. This CL `span`-ifies the callers of the APIs in
`mojo/public/cpp/system/data_pipe.h`:
* `BeginReadData` and `BeginWriteData` return (via an out parameter)
a `span` instead of returning a ptr+size pair.
* `ReadData` and `WriteData` consume a `span` instead of consuming
a ptr+size pair.
For more details see the design note here:
https://docs.google.com/document/d/1c4NKpXwpQ9MKK1SbJ4C6MvhXI8-KJZ4jq7N4VHTHJoI/edit?usp=sharing
This CL was uploaded by git cl split.
R=skyo...@chromium.org
Bug: 40284755
Change-Id: I457c0d678de7faf7f706043f101fc3af8652443b
Change diff
diff --git a/services/tracing/perfetto/consumer_host.cc b/services/tracing/perfetto/consumer_host.cc
index 0eaa7b15..85e0fca 100644
--- a/services/tracing/perfetto/consumer_host.cc
+++ b/services/tracing/perfetto/consumer_host.cc
@@ -11,6 +11,7 @@
#include <vector>
#include "base/containers/contains.h"
+#include "base/containers/span.h"
#include "base/logging.h"
#include "base/notreached.h"
#include "base/ranges/algorithm.h"
@@ -105,16 +106,14 @@
void WriteToStream(std::unique_ptr<Slice> slice, bool has_more) {
DCHECK(stream_.is_valid());
- size_t write_position = 0;
- while (write_position < slice->size()) {
- size_t write_bytes = slice->size() - write_position;
-
- MojoResult result =
- stream_->WriteData(slice->data() + write_position, &write_bytes,
- MOJO_WRITE_DATA_FLAG_NONE);
+ base::span<const uint8_t> bytes = base::as_byte_span(*slice);
+ while (!bytes.empty()) {
+ size_t actually_written_bytes = 0;
+ MojoResult result = stream_->WriteData(bytes, MOJO_WRITE_DATA_FLAG_NONE,
+ actually_written_bytes);
if (result == MOJO_RESULT_OK) {
- write_position += write_bytes;
+ bytes = bytes.subspan(actually_written_bytes);
continue;
}
Change information
Files:
- M services/tracing/perfetto/consumer_host.cc
Change size: S
Delta: 1 file changed, 7 insertions(+), 8 deletions(-)
Open in GerritRelated details
Attention is currently required from:
Submit Requirements:
Code-Coverage
Code-Review
Gerrit-MessageType: newchange
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I457c0d678de7faf7f706043f101fc3af8652443b
Gerrit-Change-Number: 5618992
Gerrit-PatchSet: 1