Skip to content

h5vcc: Use base::span for data transport in H5vccPlatformService#9288

Open
rakuco wants to merge 4 commits intoyoutube:mainfrom
rakuco:h5vcc/spanify-data-buffers
Open

h5vcc: Use base::span for data transport in H5vccPlatformService#9288
rakuco wants to merge 4 commits intoyoutube:mainfrom
rakuco:h5vcc/spanify-data-buffers

Conversation

@rakuco
Copy link
Collaborator

@rakuco rakuco commented Feb 27, 2026

Use a ReadOnlyBuffer mojom type to represent data rather than an array, as this makes the C++ bindings use base::span instead of std::vector.

Doing so allows for less duplication and fewer manual conversions, as DOMArrayBuffer can deal with spans natively, and some simplification on the browser side as well. While here, const-ify and use std::unique_ptr with base::FreeDeleter on response_ptr to avoid manual memory management.

Tested with the softmic extension on Linux.

Fixed: 487712437

Use a ReadOnlyBuffer mojom type to represent data rather than an array, as
this makes the C++ bindings use base::span instead of std::vector.

Doing so allows for less duplication and fewer manual conversions, as
DOMArrayBuffer can deal with spans natively, and some simplification on the
browser side as well. While here, const-ify and use `std::unique_ptr` with
`base::FreeDeleter` on `response_ptr` to avoid manual memory management.

Tested with the softmic extension on Linux.

Fixed: 487712437
@rakuco rakuco requested review from a team as code owners February 27, 2026 13:22
@github-actions
Copy link
Contributor

🤖 Gemini Suggested Commit Message


cobalt: Use base::span for H5vcc data transport

Update the H5vccPlatformService Mojo interface to use
mojo_base.mojom.ReadOnlyBuffer for data transport instead of array<uint8>.
This ensures that the C++ bindings utilize base::span directly, reducing
duplication and manual conversions, as DOMArrayBuffer can deal with spans
natively. This also simplifies browser and renderer side code.

Additionally, this change introduces std::unique_ptr with base::FreeDeleter
for managing response memory on the browser side, improving safety.

Bug: 487712437

💡 Pro Tips for a Better Commit Message:

  1. Influence the Result: Want to change the output? You can write custom prompts or instructions directly in the Pull Request description. The model uses that text to generate the message.
  2. Re-run the Generator: Post a comment with: /generate-commit-message

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the H5vccPlatformService to use base::span for data transport over Mojom by switching from array<uint8> to mojo_base.mojom.ReadOnlyBuffer. This is a good improvement that reduces data copying. The change also introduces std::unique_ptr with base::FreeDeleter to manage memory returned from the Starboard service, which improves memory safety by replacing manual free() calls. The changes are well-implemented across the C++ and Mojom files. I have one suggestion to ensure type safety during a numeric conversion.

@rakuco
Copy link
Collaborator Author

rakuco commented Feb 27, 2026

/gemini review

@rakuco
Copy link
Collaborator Author

rakuco commented Feb 27, 2026

cc @abhijeetk @jkim-julie @Gyuyoung

@rakuco rakuco requested a review from hlwarriner February 27, 2026 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant