Skip to content
Snippets Groups Projects
Commit 7e0b87ec authored by Darren Shen's avatar Darren Shen Committed by Chromium LUCI CQ
Browse files

Revert "`span`-ify `mojo/.../data_pipe.h`: Migrate `components/speech`."

This reverts commit 338ecedd.

Reason for revert: Depends on https://crrev.com/c/5598233 which was reverted.

Original change's description:
> `span`-ify `mojo/.../data_pipe.h`: Migrate `components/speech`.
>
> `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=evliu@google.com
>
> Bug: 40284755
> Change-Id: Iba157bc8ea436cbc6c50bc934fbbba21abac2ee6
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5619053


> Commit-Queue: Evan Liu <evliu@google.com>
> Auto-Submit: Łukasz Anforowicz <lukasza@chromium.org>
> Reviewed-by: default avatarEvan Liu <evliu@google.com>
> Cr-Commit-Position: refs/heads/main@{#1313157}

Bug: 40284755
Change-Id: Id863c84611963dd8b7932ee8b33409bc5fddb77c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5619670
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Darren Shen <shend@chromium.org>
Owners-Override: Darren Shen <shend@chromium.org>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#1313161}
parent 2c35c3da
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,6 @@
#include "components/speech/upstream_loader.h"
#include "base/containers/span.h"
#include "components/speech/upstream_loader_client.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
......@@ -47,13 +46,11 @@ void UpstreamLoader::SendData() {
return;
// Since kMaxUploadWrite is a uint32_t, no overflow occurs in this downcast.
base::span<const uint8_t> bytes_to_write =
base::as_byte_span(upload_body_).subspan(upload_position_);
bytes_to_write =
bytes_to_write.first(std::min(bytes_to_write.size(), kMaxUploadWrite));
size_t actually_written_bytes = 0;
MojoResult result = upload_pipe_->WriteData(
bytes_to_write, MOJO_WRITE_DATA_FLAG_NONE, actually_written_bytes);
size_t write_bytes =
std::min(upload_body_.length() - upload_position_, kMaxUploadWrite);
MojoResult result =
upload_pipe_->WriteData(upload_body_.data() + upload_position_,
&write_bytes, MOJO_WRITE_DATA_FLAG_NONE);
// Wait for the pipe to have more capacity available, if needed.
if (result == MOJO_RESULT_SHOULD_WAIT) {
......@@ -67,7 +64,7 @@ void UpstreamLoader::SendData() {
if (result != MOJO_RESULT_OK)
return;
upload_position_ += actually_written_bytes;
upload_position_ += write_bytes;
// If more data is available, arm the watcher again. Don't write again in a
// loop, even if WriteData would allow it, to avoid blocking the current
// thread.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment