Skip to content

Commit

Permalink
Revert "span-ify mojo/.../data_pipe.h: Migrate components/speech."
Browse files Browse the repository at this point in the history
This reverts commit 338eced.

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: Evan 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}
  • Loading branch information
darrnshn authored and Chromium LUCI CQ committed Jun 11, 2024
1 parent 2c35c3d commit 7e0b87e
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions components/speech/upstream_loader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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) {
Expand All @@ -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.
Expand Down

0 comments on commit 7e0b87e

Please sign in to comment.