spanification: automatically spanify remoting/protocol/pseudo_tcp.cc etc. [chromium/src : main]

0 views
Skip to first unread message

Daniel Angulo (Gerrit)

unread,
Jan 28, 2026, 2:44:10 PMJan 28
to Stephen Nusko, Arthur Sonzogni, AyeAye, Chromium LUCI CQ, chromotin...@chromium.org
Attention needed from Arthur Sonzogni and Stephen Nusko

Daniel Angulo voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Arthur Sonzogni
  • Stephen Nusko
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Id1a0ff3462edd3d7fa119beff620570f1893a0d8
Gerrit-Change-Number: 7526157
Gerrit-PatchSet: 2
Gerrit-Owner: Daniel Angulo <angd...@google.com>
Gerrit-Reviewer: Arthur Sonzogni <arthurs...@google.com>
Gerrit-Reviewer: Daniel Angulo <angd...@google.com>
Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
Gerrit-Attention: Stephen Nusko <nus...@chromium.org>
Gerrit-Attention: Arthur Sonzogni <arthurs...@google.com>
Gerrit-Comment-Date: Wed, 28 Jan 2026 19:44:00 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Stephen Nusko (Gerrit)

unread,
Jan 28, 2026, 11:50:21 PMJan 28
to Daniel Angulo, Arthur Sonzogni, AyeAye, Chromium LUCI CQ, chromotin...@chromium.org
Attention needed from Arthur Sonzogni and Daniel Angulo

Stephen Nusko added 15 comments

File remoting/protocol/pseudo_tcp.h
Line 225, Patchset 2 (Latest): std::unique_ptr<char[]> buffer_ GUARDED_BY(lock_);
Stephen Nusko . unresolved

While we are here switch this to a base::HeapArray? and remove `buffer_length_`? (still need data_length_ most likely).

File remoting/protocol/pseudo_tcp.cc
Line 87, Patchset 2 (Latest): auto bytes = base::U32ToBigEndian(val);
Stephen Nusko . unresolved

Because this is network code might be best to do

`base::as_bytes(base::HostToNet32(val));`

Thoughts? Here and below?

I agree that new is BigEndian so that is fine, but they have a nice helper function and it probably makes more sense to keep it consistent?

Line 137, Patchset 2 (Latest): base::as_writable_bytes(UNSAFE_BUFFERS(base::span(str, len)))
Stephen Nusko . unresolved

We can't claim UNSAFE_BUFFERS here, what SAFETY message would you write?

We have 3 options
1) Make this function take std::string_view
2) Make this function UNSAFE_BUFFER_USAGE and force all callers to add UNSAFE_TODO or UNSAFE_BUFFERS
3) Mark this as UNSAFE_TODO for now until someone can do 1 or 2.

Line 143, Patchset 2 (Latest): const uint8_t* Data() const { return data_.subspan(pos_).data(); }
Stephen Nusko . unresolved

`&data_[pos_]`

is better I think?

Line 434, Patchset 2 (Latest): // SAFETY: `buffer` is a raw C-style array of size `len`, so we can safely
// reinterpret the pointer as a span of bytes.
Stephen Nusko . unresolved

The safety concern isn't from the reinterpret it is from no knowing if the length is correct. Same as above we can't use UNSAFE_BUFFERS here.

Line 589, Patchset 2 (Latest): std::unique_ptr<uint8_t[]> buffer(new uint8_t[MAX_PACKET]);
Stephen Nusko . unresolved

Switch this to a HeapArray then you can get a span directly.

Line 594, Patchset 2 (Latest): buffer_span.first<4u>().copy_from(base::U32ToBigEndian(m_conv));
buffer_span.subspan(4u).first<4u>().copy_from(base::U32ToBigEndian(seq));
buffer_span.subspan(8u).first<4u>().copy_from(
base::U32ToBigEndian(m_rcv_nxt));
buffer_span[12] = 0;
buffer_span[13] = flags;
buffer_span.subspan(14u).first<2u>().copy_from(
base::U16ToBigEndian(static_cast<uint16_t>(m_rcv_wnd >> m_rwnd_scale)));

// Timestamp computations
buffer_span.subspan(16u).first<4u>().copy_from(base::U32ToBigEndian(now));
buffer_span.subspan(20u).first<4u>().copy_from(
base::U32ToBigEndian(m_ts_recent));
Stephen Nusko . unresolved

This looks like a SpanWriter?

Line 650, Patchset 2 (Latest): seg.conv = base::U32FromBigEndian(buffer.first<4u>());
seg.seq = base::U32FromBigEndian(buffer.subspan(4u).first<4u>());
seg.ack = base::U32FromBigEndian(buffer.subspan(8u).first<4u>());
seg.flags = buffer[13];
seg.wnd = base::U16FromBigEndian(buffer.subspan(14u).first<2u>());
seg.tsval = base::U32FromBigEndian(buffer.subspan(16u).first<4u>());
seg.tsecr = base::U32FromBigEndian(buffer.subspan(20u).first<4u>());
Stephen Nusko . unresolved

This looks like a spanReader?

Line 920, Patchset 2 (Latest): } else if (seg.data.size() != 0) {
Stephen Nusko . unresolved

nit: !seq.data.empty()

Line 943, Patchset 2 (Latest): seg.data = seg.data.first(seg.data.size() - nAdjust);
Stephen Nusko . unresolved

I think you are double moving the buffer here?

```
seg.data += nAdjust;
seg.len -= nAdjust;
```

The old code moved the buffer and then decreased the length by the same amount (to keep them in sync).

Your new code moves the buffer forward by nAdjust and then takes a further nAdjust off in addition (this is incorrect).

Delete the seq.data.first line?

Line 992, Patchset 2 (Latest): if (!m_rbuf.WriteOffset(seg.data.data(), seg.data.size(), nOffset,
Stephen Nusko . unresolved

Can we update WriteOffset?

Line 1414, Patchset 2 (Latest):bool PseudoTcp::LockedFifoBuffer::WriteOffset(const void* buffer,
size_t bytes,
Stephen Nusko . unresolved

It looks like we call this function with a span could we update this one?

Line 1425, Patchset 2 (Latest):bool PseudoTcp::LockedFifoBuffer::Read(void* buffer,
size_t bytes,
Stephen Nusko . unresolved

Can we check all of these?

Line 1498, Patchset 2 (Latest): dest(reinterpret_cast<char*>(buffer.data()), buffer.size()));
Stephen Nusko . unresolved

base::as_writable_chars(buffer) should work no?

Line 1499, Patchset 2 (Latest): base::span<const char> UNSAFE_BUFFERS(
src(&buffer_[read_position], tail_copy));
dest.first(tail_copy).copy_from(src);
base::span<const char> UNSAFE_BUFFERS(src2(&buffer_[0], copy - tail_copy));
Stephen Nusko . unresolved

base::as_chars?

Open in Gerrit

Related details

Attention is currently required from:
  • Arthur Sonzogni
  • Daniel Angulo
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Id1a0ff3462edd3d7fa119beff620570f1893a0d8
    Gerrit-Change-Number: 7526157
    Gerrit-PatchSet: 2
    Gerrit-Owner: Daniel Angulo <angd...@google.com>
    Gerrit-Reviewer: Arthur Sonzogni <arthurs...@google.com>
    Gerrit-Reviewer: Daniel Angulo <angd...@google.com>
    Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
    Gerrit-Attention: Daniel Angulo <angd...@google.com>
    Gerrit-Attention: Arthur Sonzogni <arthurs...@google.com>
    Gerrit-Comment-Date: Thu, 29 Jan 2026 04:50:00 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Daniel Angulo (Gerrit)

    unread,
    Jan 29, 2026, 3:03:10 PMJan 29
    to Arthur Sonzogni, Stephen Nusko, AyeAye, Chromium LUCI CQ, chromotin...@chromium.org
    Attention needed from Arthur Sonzogni and Stephen Nusko

    Daniel Angulo added 15 comments

    File remoting/protocol/pseudo_tcp.h
    Line 225, Patchset 2: std::unique_ptr<char[]> buffer_ GUARDED_BY(lock_);
    Stephen Nusko . resolved

    While we are here switch this to a base::HeapArray? and remove `buffer_length_`? (still need data_length_ most likely).

    Daniel Angulo

    Done

    File remoting/protocol/pseudo_tcp.cc
    Line 87, Patchset 2: auto bytes = base::U32ToBigEndian(val);
    Stephen Nusko . resolved

    Because this is network code might be best to do

    `base::as_bytes(base::HostToNet32(val));`

    Thoughts? Here and below?

    I agree that new is BigEndian so that is fine, but they have a nice helper function and it probably makes more sense to keep it consistent?

    Daniel Angulo

    Done

    Line 137, Patchset 2: base::as_writable_bytes(UNSAFE_BUFFERS(base::span(str, len)))
    Stephen Nusko . unresolved

    We can't claim UNSAFE_BUFFERS here, what SAFETY message would you write?

    We have 3 options
    1) Make this function take std::string_view
    2) Make this function UNSAFE_BUFFER_USAGE and force all callers to add UNSAFE_TODO or UNSAFE_BUFFERS
    3) Mark this as UNSAFE_TODO for now until someone can do 1 or 2.

    Daniel Angulo

    I was thinking that string_view can't be used because it needs to write data on it, but making this function take a span<char> would work instead. However this function is not used anywhare, should I stray it?

    Line 143, Patchset 2: const uint8_t* Data() const { return data_.subspan(pos_).data(); }
    Stephen Nusko . resolved

    `&data_[pos_]`

    is better I think?

    Daniel Angulo

    Done

    Line 434, Patchset 2: // SAFETY: `buffer` is a raw C-style array of size `len`, so we can safely

    // reinterpret the pointer as a span of bytes.
    Stephen Nusko . resolved

    The safety concern isn't from the reinterpret it is from no knowing if the length is correct. Same as above we can't use UNSAFE_BUFFERS here.

    Daniel Angulo

    Done

    Line 589, Patchset 2: std::unique_ptr<uint8_t[]> buffer(new uint8_t[MAX_PACKET]);
    Stephen Nusko . resolved

    Switch this to a HeapArray then you can get a span directly.

    Daniel Angulo

    Done

    Line 594, Patchset 2: buffer_span.first<4u>().copy_from(base::U32ToBigEndian(m_conv));

    buffer_span.subspan(4u).first<4u>().copy_from(base::U32ToBigEndian(seq));
    buffer_span.subspan(8u).first<4u>().copy_from(
    base::U32ToBigEndian(m_rcv_nxt));
    buffer_span[12] = 0;
    buffer_span[13] = flags;
    buffer_span.subspan(14u).first<2u>().copy_from(
    base::U16ToBigEndian(static_cast<uint16_t>(m_rcv_wnd >> m_rwnd_scale)));

    // Timestamp computations
    buffer_span.subspan(16u).first<4u>().copy_from(base::U32ToBigEndian(now));
    buffer_span.subspan(20u).first<4u>().copy_from(
    base::U32ToBigEndian(m_ts_recent));
    Stephen Nusko . resolved

    This looks like a SpanWriter?

    Daniel Angulo

    Done

    Line 650, Patchset 2: seg.conv = base::U32FromBigEndian(buffer.first<4u>());

    seg.seq = base::U32FromBigEndian(buffer.subspan(4u).first<4u>());
    seg.ack = base::U32FromBigEndian(buffer.subspan(8u).first<4u>());
    seg.flags = buffer[13];
    seg.wnd = base::U16FromBigEndian(buffer.subspan(14u).first<2u>());
    seg.tsval = base::U32FromBigEndian(buffer.subspan(16u).first<4u>());
    seg.tsecr = base::U32FromBigEndian(buffer.subspan(20u).first<4u>());
    Stephen Nusko . resolved

    This looks like a spanReader?

    Daniel Angulo

    Done

    Line 920, Patchset 2: } else if (seg.data.size() != 0) {
    Stephen Nusko . resolved

    nit: !seq.data.empty()

    Daniel Angulo

    Done

    Line 943, Patchset 2: seg.data = seg.data.first(seg.data.size() - nAdjust);
    Stephen Nusko . resolved

    I think you are double moving the buffer here?

    ```
    seg.data += nAdjust;
    seg.len -= nAdjust;
    ```

    The old code moved the buffer and then decreased the length by the same amount (to keep them in sync).

    Your new code moves the buffer forward by nAdjust and then takes a further nAdjust off in addition (this is incorrect).

    Delete the seq.data.first line?

    Daniel Angulo

    Done

    Line 992, Patchset 2: if (!m_rbuf.WriteOffset(seg.data.data(), seg.data.size(), nOffset,
    Stephen Nusko . resolved

    Can we update WriteOffset?

    Daniel Angulo

    Done

    Line 1414, Patchset 2:bool PseudoTcp::LockedFifoBuffer::WriteOffset(const void* buffer,
    size_t bytes,
    Stephen Nusko . resolved

    It looks like we call this function with a span could we update this one?

    Daniel Angulo

    Done

    Line 1425, Patchset 2:bool PseudoTcp::LockedFifoBuffer::Read(void* buffer,
    size_t bytes,
    Stephen Nusko . resolved

    Can we check all of these?

    Daniel Angulo

    Done

    Line 1498, Patchset 2: dest(reinterpret_cast<char*>(buffer.data()), buffer.size()));
    Stephen Nusko . resolved

    base::as_writable_chars(buffer) should work no?

    Daniel Angulo

    Done

    Line 1499, Patchset 2: base::span<const char> UNSAFE_BUFFERS(

    src(&buffer_[read_position], tail_copy));
    dest.first(tail_copy).copy_from(src);
    base::span<const char> UNSAFE_BUFFERS(src2(&buffer_[0], copy - tail_copy));
    Stephen Nusko . resolved

    base::as_chars?

    Daniel Angulo

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Arthur Sonzogni
    • Stephen Nusko
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Id1a0ff3462edd3d7fa119beff620570f1893a0d8
    Gerrit-Change-Number: 7526157
    Gerrit-PatchSet: 5
    Gerrit-Owner: Daniel Angulo <angd...@google.com>
    Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Reviewer: Daniel Angulo <angd...@google.com>
    Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
    Gerrit-Attention: Stephen Nusko <nus...@chromium.org>
    Gerrit-Attention: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Comment-Date: Thu, 29 Jan 2026 20:03:00 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Stephen Nusko <nus...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Stephen Nusko (Gerrit)

    unread,
    Jan 29, 2026, 8:52:28 PMJan 29
    to Daniel Angulo, Arthur Sonzogni, AyeAye, Chromium LUCI CQ, chromotin...@chromium.org
    Attention needed from Arthur Sonzogni and Daniel Angulo

    Stephen Nusko added 7 comments

    File remoting/protocol/pseudo_tcp.cc
    Line 137, Patchset 2: base::as_writable_bytes(UNSAFE_BUFFERS(base::span(str, len)))
    Stephen Nusko . unresolved

    We can't claim UNSAFE_BUFFERS here, what SAFETY message would you write?

    We have 3 options
    1) Make this function take std::string_view
    2) Make this function UNSAFE_BUFFER_USAGE and force all callers to add UNSAFE_TODO or UNSAFE_BUFFERS
    3) Mark this as UNSAFE_TODO for now until someone can do 1 or 2.

    Daniel Angulo

    I was thinking that string_view can't be used because it needs to write data on it, but making this function take a span<char> would work instead. However this function is not used anywhare, should I stray it?

    Stephen Nusko

    If this function isn't used we should just delete it I think?

    I guess the API it is copied from has one, so we could keep it.

    Also I think std::string_view is fine? we are writing a string so accepting a string and converting it to bytes seems fine?

    Line 501, Patchset 5 (Latest): base::as_writable_bytes(UNSAFE_BUFFERS(base::span(buffer, len))),
    Stephen Nusko . unresolved

    We can't use UNSAFE_BUFFERS here still, we have the same issue as the other location.

    Line 558, Patchset 5 (Latest):uint32_t PseudoTcp::queue(const char* data, uint32_t len, bool bCtrl) {
    Stephen Nusko . unresolved

    Can we make this a span as well?

    Line 652, Patchset 5 (Latest): reader.Skip(1u);
    Stephen Nusko . unresolved

    What is this skip? isn't flags at position 13?

    `ack` = `buffer + 8` which is U32 so 4 bytes so ends at `buffer + 12`, and then we do `seq.flags = buffer[13]`; but in the new code we `Skip(1u)`?

    Line 750, Patchset 5 (Latest): parseOptions(seg.data.subspan(1u));
    Stephen Nusko . unresolved

    nit: template subspan<1u>

    Line 1385, Patchset 5 (Latest): const size_t tail_copy = std::min(copy, buffer_.size() - read_position_);

    new_buffer.subspan(0, tail_copy)
    .copy_from(buffer_.subspan(read_position_, tail_copy));
    new_buffer.subspan(tail_copy, copy - tail_copy)
    .copy_from(buffer_.subspan(0, copy - tail_copy));
    Stephen Nusko . unresolved

    could this be written as a base::span::split? I think so?

    Line 1479, Patchset 5 (Latest): base::span<char> dest = base::as_writable_chars(buffer);
    base::span<const char> src =
    base::as_chars(buffer_.subspan(read_position, tail_copy));
    dest.first(tail_copy).copy_from(src);
    base::span<const char> src2 =
    base::as_chars(buffer_.subspan(0, copy - tail_copy));
    dest.subspan(tail_copy, copy - tail_copy).copy_from(src2);
    Stephen Nusko . unresolved

    I didn't fully math this out but also feels like a split of some sort?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Arthur Sonzogni
    • Daniel Angulo
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Id1a0ff3462edd3d7fa119beff620570f1893a0d8
    Gerrit-Change-Number: 7526157
    Gerrit-PatchSet: 5
    Gerrit-Owner: Daniel Angulo <angd...@google.com>
    Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Reviewer: Daniel Angulo <angd...@google.com>
    Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
    Gerrit-Attention: Daniel Angulo <angd...@google.com>
    Gerrit-Attention: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Comment-Date: Fri, 30 Jan 2026 01:51:55 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Stephen Nusko <nus...@chromium.org>
    Comment-In-Reply-To: Daniel Angulo <angd...@google.com>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Daniel Angulo (Gerrit)

    unread,
    Jan 30, 2026, 11:30:01 AMJan 30
    to Arthur Sonzogni, Stephen Nusko, AyeAye, Chromium LUCI CQ, chromotin...@chromium.org
    Attention needed from Arthur Sonzogni and Stephen Nusko

    Daniel Angulo added 7 comments

    File remoting/protocol/pseudo_tcp.cc
    Line 137, Patchset 2: base::as_writable_bytes(UNSAFE_BUFFERS(base::span(str, len)))
    Stephen Nusko . unresolved

    We can't claim UNSAFE_BUFFERS here, what SAFETY message would you write?

    We have 3 options
    1) Make this function take std::string_view
    2) Make this function UNSAFE_BUFFER_USAGE and force all callers to add UNSAFE_TODO or UNSAFE_BUFFERS
    3) Mark this as UNSAFE_TODO for now until someone can do 1 or 2.

    Daniel Angulo

    I was thinking that string_view can't be used because it needs to write data on it, but making this function take a span<char> would work instead. However this function is not used anywhare, should I stray it?

    Stephen Nusko

    If this function isn't used we should just delete it I think?

    I guess the API it is copied from has one, so we could keep it.

    Also I think std::string_view is fine? we are writing a string so accepting a string and converting it to bytes seems fine?

    Daniel Angulo

    isn't it writing data+pos into the same str that is the parameter?

    Line 501, Patchset 5: base::as_writable_bytes(UNSAFE_BUFFERS(base::span(buffer, len))),
    Stephen Nusko . resolved

    We can't use UNSAFE_BUFFERS here still, we have the same issue as the other location.

    Daniel Angulo

    Done

    Line 558, Patchset 5:uint32_t PseudoTcp::queue(const char* data, uint32_t len, bool bCtrl) {
    Stephen Nusko . resolved

    Can we make this a span as well?

    Daniel Angulo

    Done

    Line 652, Patchset 5: reader.Skip(1u);
    Stephen Nusko . unresolved

    What is this skip? isn't flags at position 13?

    `ack` = `buffer + 8` which is U32 so 4 bytes so ends at `buffer + 12`, and then we do `seq.flags = buffer[13]`; but in the new code we `Skip(1u)`?

    Daniel Angulo

    in the writter we have buff[12] = 0; (which is the position 13) then buff[13] = flags (which is position 14). If I disable the skip then a bunch of tests start to fail

    Line 750, Patchset 5: parseOptions(seg.data.subspan(1u));
    Stephen Nusko . resolved

    nit: template subspan<1u>

    Daniel Angulo

    Done

    Line 1385, Patchset 5: const size_t tail_copy = std::min(copy, buffer_.size() - read_position_);


    new_buffer.subspan(0, tail_copy)
    .copy_from(buffer_.subspan(read_position_, tail_copy));
    new_buffer.subspan(tail_copy, copy - tail_copy)
    .copy_from(buffer_.subspan(0, copy - tail_copy));
    Stephen Nusko . resolved

    could this be written as a base::span::split? I think so?

    Daniel Angulo

    Done

    Line 1479, Patchset 5: base::span<char> dest = base::as_writable_chars(buffer);

    base::span<const char> src =
    base::as_chars(buffer_.subspan(read_position, tail_copy));
    dest.first(tail_copy).copy_from(src);
    base::span<const char> src2 =
    base::as_chars(buffer_.subspan(0, copy - tail_copy));
    dest.subspan(tail_copy, copy - tail_copy).copy_from(src2);
    Stephen Nusko . resolved

    I didn't fully math this out but also feels like a split of some sort?

    Daniel Angulo

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Arthur Sonzogni
    • Stephen Nusko
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Id1a0ff3462edd3d7fa119beff620570f1893a0d8
    Gerrit-Change-Number: 7526157
    Gerrit-PatchSet: 6
    Gerrit-Owner: Daniel Angulo <angd...@google.com>
    Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Reviewer: Daniel Angulo <angd...@google.com>
    Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
    Gerrit-Attention: Stephen Nusko <nus...@chromium.org>
    Gerrit-Attention: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Comment-Date: Fri, 30 Jan 2026 16:29:45 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Stephen Nusko (Gerrit)

    unread,
    Feb 1, 2026, 11:50:17 PMFeb 1
    to Daniel Angulo, Arthur Sonzogni, AyeAye, Chromium LUCI CQ, chromotin...@chromium.org
    Attention needed from Arthur Sonzogni and Daniel Angulo

    Stephen Nusko added 11 comments

    File remoting/protocol/pseudo_tcp.cc
    Line 137, Patchset 2: base::as_writable_bytes(UNSAFE_BUFFERS(base::span(str, len)))
    Stephen Nusko . unresolved

    We can't claim UNSAFE_BUFFERS here, what SAFETY message would you write?

    We have 3 options
    1) Make this function take std::string_view
    2) Make this function UNSAFE_BUFFER_USAGE and force all callers to add UNSAFE_TODO or UNSAFE_BUFFERS
    3) Mark this as UNSAFE_TODO for now until someone can do 1 or 2.

    Daniel Angulo

    I was thinking that string_view can't be used because it needs to write data on it, but making this function take a span<char> would work instead. However this function is not used anywhare, should I stray it?

    Stephen Nusko

    If this function isn't used we should just delete it I think?

    I guess the API it is copied from has one, so we could keep it.

    Also I think std::string_view is fine? we are writing a string so accepting a string and converting it to bytes seems fine?

    Daniel Angulo

    isn't it writing data+pos into the same str that is the parameter?

    Stephen Nusko

    Obviously a char span works, but an std::string_view can be converted to a span cheaply so I'm not sure I follow the concern?

    Since you already have to do base::as_writable_byte_span there is no difference but API clarity that you have a string? So better to use an std::string_view no?

    Line 140, Patchset 6 (Latest): // SAFETY: `str` is a raw char*, but we immediately convert it to a span of
    // bytes, which makes our intentions clear and prevents buffer overflows.
    Stephen Nusko . unresolved

    No need for a safety comment.

    Line 590, Patchset 6 (Latest): base::span<uint8_t> buffer(buffer_storage);
    Stephen Nusko . unresolved

    You don't need this variable, just pass `buffer_storage` directly into the SpanWriter.

    And use the `subspan` method on `buffer_storage` directly for ReadOffset call.

    Line 652, Patchset 5: reader.Skip(1u);
    Stephen Nusko . unresolved

    What is this skip? isn't flags at position 13?

    `ack` = `buffer + 8` which is U32 so 4 bytes so ends at `buffer + 12`, and then we do `seq.flags = buffer[13]`; but in the new code we `Skip(1u)`?

    Daniel Angulo

    in the writter we have buff[12] = 0; (which is the position 13) then buff[13] = flags (which is position 14). If I disable the skip then a bunch of tests start to fail

    Stephen Nusko

    Perfect can you add a comment mentioning this? Makes sense.

    Line 1260, Patchset 6 (Latest): // SAFETY: buf.Data() is a pointer to uint8_t of size buf.Length(), and we
    // cast it to a pointer to char of that size.
    queue(UNSAFE_BUFFERS(base::span(reinterpret_cast<const char*>(buf.Data()),
    static_cast<uint32_t>(buf.Length()))),
    Stephen Nusko . unresolved

    We own the ByteBufferWriter type here in our code, and are already modifying it. Can we just add a data() and size() method to it so it can directly construct a span and then we can use `as_writable_bytes`?

    Then remove the SAFETY comment.

    Line 1389, Patchset 6 (Latest): new_buffer_first.copy_from(buffer_.subspan(read_position_, tail_copy));
    Stephen Nusko . unresolved

    copy_from_nonoverlapping (these are separate heap arrays they can't be the same memory).

    Line 1503, Patchset 6 (Latest): const size_t tail_copy = std::min(copy, buffer_.size() - write_position);
    buffer_.subspan(write_position, tail_copy)
    .copy_from(base::as_chars(buffer.first(tail_copy)));
    buffer_.first(copy - tail_copy)
    .copy_from(base::as_chars(buffer.subspan(tail_copy, copy - tail_copy)));
    Stephen Nusko . unresolved

    Switch this into a split as well?

    File remoting/protocol/pseudo_tcp_unittest.cc
    Line 196, Patchset 6 (Latest): UNSAFE_BUFFERS(base::span(packet.c_str(), packet.size())));
    Stephen Nusko . unresolved

    We don't need this UNSAFE_BUFFERS

    Just make a string_view or use `base::as_writable_chars`

    Line 361, Patchset 6 (Latest): received = remote_.Recv(base::span(block).first(block.size()));
    Stephen Nusko . unresolved

    first(block.size) of a span of block doesn't make any difference. Remove .first()

    Line 525, Patchset 6 (Latest): received = receiver_->Recv(base::span(block).first(block.size()));
    Stephen Nusko . unresolved

    Also review this and other calls for redundant first calls.

    File remoting/protocol/pseudotcp_adapter.cc
    Line 166, Patchset 6 (Latest): base::span(buffer->data(), static_cast<size_t>(buffer_size))));
    Stephen Nusko . unresolved

    Can't you juse use `buffer.span()`? here and below?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Arthur Sonzogni
    • Daniel Angulo
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Id1a0ff3462edd3d7fa119beff620570f1893a0d8
    Gerrit-Change-Number: 7526157
    Gerrit-PatchSet: 6
    Gerrit-Owner: Daniel Angulo <angd...@google.com>
    Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Reviewer: Daniel Angulo <angd...@google.com>
    Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
    Gerrit-Attention: Daniel Angulo <angd...@google.com>
    Gerrit-Attention: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Comment-Date: Mon, 02 Feb 2026 04:49:46 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Arthur Sonzogni (Gerrit)

    unread,
    Feb 10, 2026, 8:51:21 AMFeb 10
    to Daniel Angulo, Code Review Nudger, Stephen Nusko, AyeAye, Chromium LUCI CQ, chromotin...@chromium.org
    Attention needed from Daniel Angulo

    Arthur Sonzogni added 1 comment

    Patchset-level comments
    File-level comment, Patchset 6 (Latest):
    Arthur Sonzogni . unresolved

    Thanks!
    (I am waiting for the current suggestion to be addressed + the build to pass)
    Feel free to close this comment when this patch is ready to be reviewed again.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Daniel Angulo
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Id1a0ff3462edd3d7fa119beff620570f1893a0d8
    Gerrit-Change-Number: 7526157
    Gerrit-PatchSet: 6
    Gerrit-Owner: Daniel Angulo <angd...@google.com>
    Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Reviewer: Daniel Angulo <angd...@google.com>
    Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
    Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
    Gerrit-Attention: Daniel Angulo <angd...@google.com>
    Gerrit-Comment-Date: Tue, 10 Feb 2026 13:51:07 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Daniel Angulo (Gerrit)

    unread,
    Feb 10, 2026, 4:48:26 PMFeb 10
    to Code Review Nudger, Arthur Sonzogni, Stephen Nusko, AyeAye, Chromium LUCI CQ, chromotin...@chromium.org
    Attention needed from Arthur Sonzogni and Stephen Nusko

    Daniel Angulo added 13 comments

    Patchset-level comments
    File-level comment, Patchset 6:
    Arthur Sonzogni . resolved

    Thanks!
    (I am waiting for the current suggestion to be addressed + the build to pass)
    Feel free to close this comment when this patch is ready to be reviewed again.

    Daniel Angulo

    Done

    File remoting/protocol/pseudo_tcp.cc
    Line 137, Patchset 2: base::as_writable_bytes(UNSAFE_BUFFERS(base::span(str, len)))
    Stephen Nusko . unresolved

    We can't claim UNSAFE_BUFFERS here, what SAFETY message would you write?

    We have 3 options
    1) Make this function take std::string_view
    2) Make this function UNSAFE_BUFFER_USAGE and force all callers to add UNSAFE_TODO or UNSAFE_BUFFERS
    3) Mark this as UNSAFE_TODO for now until someone can do 1 or 2.

    Daniel Angulo

    I was thinking that string_view can't be used because it needs to write data on it, but making this function take a span<char> would work instead. However this function is not used anywhare, should I stray it?

    Stephen Nusko

    If this function isn't used we should just delete it I think?

    I guess the API it is copied from has one, so we could keep it.

    Also I think std::string_view is fine? we are writing a string so accepting a string and converting it to bytes seems fine?

    Daniel Angulo

    isn't it writing data+pos into the same str that is the parameter?

    Stephen Nusko

    Obviously a char span works, but an std::string_view can be converted to a span cheaply so I'm not sure I follow the concern?

    Since you already have to do base::as_writable_byte_span there is no difference but API clarity that you have a string? So better to use an std::string_view no?

    Daniel Angulo

    base::as_writable_byte_span cannot be used with a std::string_view. Here's why

    std::string_view is Read-Only: A std::string_view (and absl::string_view) provides a non-owning, read-only view into an existing character sequence. It doesn't own the data and cannot be used to modify it.

    Line 140, Patchset 6: // SAFETY: `str` is a raw char*, but we immediately convert it to a span of

    // bytes, which makes our intentions clear and prevents buffer overflows.
    Stephen Nusko . resolved

    No need for a safety comment.

    Daniel Angulo

    Done

    Line 590, Patchset 6: base::span<uint8_t> buffer(buffer_storage);
    Stephen Nusko . resolved

    You don't need this variable, just pass `buffer_storage` directly into the SpanWriter.

    And use the `subspan` method on `buffer_storage` directly for ReadOffset call.

    Daniel Angulo
    no viable constructor or deduction guide for deduction of template arguments of 'base::SpanWriter'
    589 | base::SpanWriter writer(buffer_storage);
    Line 652, Patchset 5: reader.Skip(1u);
    Stephen Nusko . resolved

    What is this skip? isn't flags at position 13?

    `ack` = `buffer + 8` which is U32 so 4 bytes so ends at `buffer + 12`, and then we do `seq.flags = buffer[13]`; but in the new code we `Skip(1u)`?

    Daniel Angulo

    in the writter we have buff[12] = 0; (which is the position 13) then buff[13] = flags (which is position 14). If I disable the skip then a bunch of tests start to fail

    Stephen Nusko

    Perfect can you add a comment mentioning this? Makes sense.

    Daniel Angulo

    Done

    Line 1260, Patchset 6: // SAFETY: buf.Data() is a pointer to uint8_t of size buf.Length(), and we

    // cast it to a pointer to char of that size.
    queue(UNSAFE_BUFFERS(base::span(reinterpret_cast<const char*>(buf.Data()),
    static_cast<uint32_t>(buf.Length()))),
    Stephen Nusko . resolved

    We own the ByteBufferWriter type here in our code, and are already modifying it. Can we just add a data() and size() method to it so it can directly construct a span and then we can use `as_writable_bytes`?

    Then remove the SAFETY comment.

    Daniel Angulo

    Done

    Line 1389, Patchset 6: new_buffer_first.copy_from(buffer_.subspan(read_position_, tail_copy));
    Stephen Nusko . resolved

    copy_from_nonoverlapping (these are separate heap arrays they can't be the same memory).

    Daniel Angulo

    Done

    Line 1385, Patchset 5: const size_t tail_copy = std::min(copy, buffer_.size() - read_position_);

    new_buffer.subspan(0, tail_copy)
    .copy_from(buffer_.subspan(read_position_, tail_copy));
    new_buffer.subspan(tail_copy, copy - tail_copy)
    .copy_from(buffer_.subspan(0, copy - tail_copy));
    Stephen Nusko . resolved

    could this be written as a base::span::split? I think so?

    Daniel Angulo

    Done

    Daniel Angulo

    how? I see that there could be a split at tail_copy, but buffer_.subspan(0, copy - tail_copy) starts at offset 0 not at tail_copy, maybe I'm just a little bit confused but I don't see a clean split

    Line 1503, Patchset 6: const size_t tail_copy = std::min(copy, buffer_.size() - write_position);

    buffer_.subspan(write_position, tail_copy)
    .copy_from(base::as_chars(buffer.first(tail_copy)));
    buffer_.first(copy - tail_copy)
    .copy_from(base::as_chars(buffer.subspan(tail_copy, copy - tail_copy)));
    Stephen Nusko . resolved

    Switch this into a split as well?

    Daniel Angulo

    Done

    File remoting/protocol/pseudo_tcp_unittest.cc
    Line 196, Patchset 6: UNSAFE_BUFFERS(base::span(packet.c_str(), packet.size())));
    Stephen Nusko . resolved

    We don't need this UNSAFE_BUFFERS

    Just make a string_view or use `base::as_writable_chars`

    Daniel Angulo

    Done

    Line 361, Patchset 6: received = remote_.Recv(base::span(block).first(block.size()));
    Stephen Nusko . resolved

    first(block.size) of a span of block doesn't make any difference. Remove .first()

    Daniel Angulo

    Done

    Line 525, Patchset 6: received = receiver_->Recv(base::span(block).first(block.size()));
    Stephen Nusko . resolved

    Also review this and other calls for redundant first calls.

    Daniel Angulo

    Done

    File remoting/protocol/pseudotcp_adapter.cc
    Line 166, Patchset 6: base::span(buffer->data(), static_cast<size_t>(buffer_size))));
    Stephen Nusko . resolved

    Can't you juse use `buffer.span()`? here and below?

    Daniel Angulo

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Arthur Sonzogni
    • Stephen Nusko
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Id1a0ff3462edd3d7fa119beff620570f1893a0d8
    Gerrit-Change-Number: 7526157
    Gerrit-PatchSet: 8
    Gerrit-Owner: Daniel Angulo <angd...@google.com>
    Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Reviewer: Daniel Angulo <angd...@google.com>
    Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
    Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
    Gerrit-Attention: Stephen Nusko <nus...@chromium.org>
    Gerrit-Attention: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Comment-Date: Tue, 10 Feb 2026 21:48:18 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Stephen Nusko <nus...@chromium.org>
    Comment-In-Reply-To: Daniel Angulo <angd...@google.com>
    Comment-In-Reply-To: Arthur Sonzogni <arthurs...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Arthur Sonzogni (Gerrit)

    unread,
    Feb 12, 2026, 4:26:33 AMFeb 12
    to Daniel Angulo, Code Review Nudger, Stephen Nusko, AyeAye, Chromium LUCI CQ, chromotin...@chromium.org
    Attention needed from Daniel Angulo and Stephen Nusko

    Arthur Sonzogni added 6 comments

    File remoting/protocol/pseudo_tcp.cc
    Line 498, Patchset 8 (Latest):int PseudoTcp::Recv(base::span<char> buffer) {
    Arthur Sonzogni . unresolved

    Could this be uint8_t?

    Line 505, Patchset 8 (Latest): if (!m_rbuf.Read(base::as_writable_bytes(buffer), &read)) {
    Arthur Sonzogni . unresolved

    This can be removed after applying my previous comment.

    File remoting/protocol/pseudotcp_adapter.cc
    Line 156, Patchset 8 (Latest): int buffer_size,
    Arthur Sonzogni . unresolved

    Can we `CHECK_EQ(buffer->span().size(), buffer_size)`.

    Eventually, the `buffer_size` argument would be removed, but this is going to take additional refactoring.

    Line 162, Patchset 8 (Latest):
    // SAFETY: buffer_size is the size of the buffer, and the buffer is a pointer
    // to char of that size.
    Arthur Sonzogni . unresolved

    We don't need a "safety" comment here. There are no UNSAFE_BUFERS

    Line 165, Patchset 8 (Latest): int result = pseudo_tcp_.Recv(base::as_writable_chars(buffer->span()));
    Arthur Sonzogni . unresolved

    This can be removed if you apply one of my other comments about passing `base::span<uint8_t>`

    Line 184, Patchset 8 (Latest): int buffer_size,
    Arthur Sonzogni . unresolved

    ditto

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Daniel Angulo
    • Stephen Nusko
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Id1a0ff3462edd3d7fa119beff620570f1893a0d8
    Gerrit-Change-Number: 7526157
    Gerrit-PatchSet: 8
    Gerrit-Owner: Daniel Angulo <angd...@google.com>
    Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Reviewer: Daniel Angulo <angd...@google.com>
    Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
    Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
    Gerrit-Attention: Stephen Nusko <nus...@chromium.org>
    Gerrit-Attention: Daniel Angulo <angd...@google.com>
    Gerrit-Comment-Date: Thu, 12 Feb 2026 09:26:20 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Daniel Angulo (Gerrit)

    unread,
    Feb 12, 2026, 12:27:03 PMFeb 12
    to Code Review Nudger, Arthur Sonzogni, Stephen Nusko, AyeAye, Chromium LUCI CQ, chromotin...@chromium.org
    Attention needed from Arthur Sonzogni and Stephen Nusko

    Daniel Angulo added 5 comments

    File remoting/protocol/pseudo_tcp.cc
    Line 498, Patchset 8:int PseudoTcp::Recv(base::span<char> buffer) {
    Arthur Sonzogni . resolved

    Could this be uint8_t?

    Daniel Angulo

    Done

    Line 505, Patchset 8: if (!m_rbuf.Read(base::as_writable_bytes(buffer), &read)) {
    Arthur Sonzogni . resolved

    This can be removed after applying my previous comment.

    Daniel Angulo

    Done

    File remoting/protocol/pseudotcp_adapter.cc
    Line 156, Patchset 8: int buffer_size,
    Arthur Sonzogni . unresolved

    Can we `CHECK_EQ(buffer->span().size(), buffer_size)`.

    Eventually, the `buffer_size` argument would be removed, but this is going to take additional refactoring.

    Daniel Angulo

    check_eq is throwing error because buffer->span() and buffer_size are not equal, have just added .first(buffer_size) to the Recv call


    // SAFETY: buffer_size is the size of the buffer, and the buffer is a pointer
    // to char of that size.
    Arthur Sonzogni . resolved

    We don't need a "safety" comment here. There are no UNSAFE_BUFERS

    Daniel Angulo

    Done

    Line 165, Patchset 8: int result = pseudo_tcp_.Recv(base::as_writable_chars(buffer->span()));
    Arthur Sonzogni . resolved

    This can be removed if you apply one of my other comments about passing `base::span<uint8_t>`

    Daniel Angulo

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Arthur Sonzogni
    • Stephen Nusko
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Id1a0ff3462edd3d7fa119beff620570f1893a0d8
    Gerrit-Change-Number: 7526157
    Gerrit-PatchSet: 9
    Gerrit-Owner: Daniel Angulo <angd...@google.com>
    Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Reviewer: Daniel Angulo <angd...@google.com>
    Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
    Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
    Gerrit-Attention: Stephen Nusko <nus...@chromium.org>
    Gerrit-Attention: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Comment-Date: Thu, 12 Feb 2026 17:26:54 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Arthur Sonzogni <arthurs...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Arthur Sonzogni (Gerrit)

    unread,
    Feb 13, 2026, 10:07:29 AMFeb 13
    to Daniel Angulo, Code Review Nudger, Stephen Nusko, AyeAye, Chromium LUCI CQ, chromotin...@chromium.org
    Attention needed from Daniel Angulo and Stephen Nusko

    Arthur Sonzogni added 6 comments

    File remoting/protocol/pseudo_tcp.h
    Line 81, Patchset 9 (Latest): bool NotifyPacket(base::span<const char> buffer);
    Arthur Sonzogni . unresolved

    Optional: Ma

    File remoting/protocol/pseudotcp_adapter.cc
    Line 162, Patchset 9 (Latest): int result = pseudo_tcp_.Recv(buffer->span().first(buffer_size));
    Arthur Sonzogni . unresolved

    This could be `first` directly.

    Line 189, Patchset 9 (Latest): int result = pseudo_tcp_.Send(buffer->span().first(buffer_size));
    Arthur Sonzogni . unresolved

    this could be `first`

    Line 261, Patchset 9 (Latest): // SAFETY: read_buffer_size_ is the size of the buffer, and the buffer is a
    // pointer to char of that size.
    int result = pseudo_tcp_.Recv(UNSAFE_BUFFERS(
    base::span(reinterpret_cast<uint8_t*>(read_buffer_->data()),
    static_cast<size_t>(read_buffer_size_))));
    Arthur Sonzogni . unresolved

    We could avoid `UNSAFE_BUFFERS`, here because `read_buffer_->first(read_buffer_size_)` exist.

    (There is also `->span()` for the full span)

    Line 290, Patchset 9 (Latest):
    // SAFETY: write_buffer_size_ is the size of the buffer, and the buffer is a
    // pointer to char of that size.
    int result = pseudo_tcp_.Send(UNSAFE_BUFFERS(
    base::span(reinterpret_cast<uint8_t*>(write_buffer_->data()),
    static_cast<size_t>(write_buffer_size_))));
    Arthur Sonzogni . unresolved

    Ditto

    Line 433, Patchset 9 (Latest): pseudo_tcp_.NotifyPacket(UNSAFE_BUFFERS(
    Arthur Sonzogni . unresolved

    Ditto

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Daniel Angulo
    • Stephen Nusko
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Id1a0ff3462edd3d7fa119beff620570f1893a0d8
    Gerrit-Change-Number: 7526157
    Gerrit-PatchSet: 9
    Gerrit-Owner: Daniel Angulo <angd...@google.com>
    Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Reviewer: Daniel Angulo <angd...@google.com>
    Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
    Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
    Gerrit-Attention: Stephen Nusko <nus...@chromium.org>
    Gerrit-Attention: Daniel Angulo <angd...@google.com>
    Gerrit-Comment-Date: Fri, 13 Feb 2026 15:07:12 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Daniel Angulo (Gerrit)

    unread,
    Feb 13, 2026, 4:59:24 PMFeb 13
    to Code Review Nudger, Arthur Sonzogni, Stephen Nusko, AyeAye, Chromium LUCI CQ, chromotin...@chromium.org
    Attention needed from Arthur Sonzogni and Stephen Nusko

    Daniel Angulo added 7 comments

    File remoting/protocol/pseudo_tcp.h
    Line 81, Patchset 9: bool NotifyPacket(base::span<const char> buffer);
    Arthur Sonzogni . resolved

    Optional: Ma

    Daniel Angulo

    Ma?

    File remoting/protocol/pseudotcp_adapter.cc
    Line 162, Patchset 9: int result = pseudo_tcp_.Recv(buffer->span().first(buffer_size));
    Arthur Sonzogni . resolved

    This could be `first` directly.

    Daniel Angulo

    Done

    Line 184, Patchset 8: int buffer_size,
    Arthur Sonzogni . resolved

    ditto

    Daniel Angulo

    Done

    Line 189, Patchset 9: int result = pseudo_tcp_.Send(buffer->span().first(buffer_size));
    Arthur Sonzogni . resolved

    this could be `first`

    Daniel Angulo

    Done

    Line 261, Patchset 9: // SAFETY: read_buffer_size_ is the size of the buffer, and the buffer is a

    // pointer to char of that size.
    int result = pseudo_tcp_.Recv(UNSAFE_BUFFERS(
    base::span(reinterpret_cast<uint8_t*>(read_buffer_->data()),
    static_cast<size_t>(read_buffer_size_))));
    Arthur Sonzogni . resolved

    We could avoid `UNSAFE_BUFFERS`, here because `read_buffer_->first(read_buffer_size_)` exist.

    (There is also `->span()` for the full span)

    Daniel Angulo

    Done


    // SAFETY: write_buffer_size_ is the size of the buffer, and the buffer is a
    // pointer to char of that size.
    int result = pseudo_tcp_.Send(UNSAFE_BUFFERS(
    base::span(reinterpret_cast<uint8_t*>(write_buffer_->data()),
    static_cast<size_t>(write_buffer_size_))));
    Arthur Sonzogni . resolved

    Ditto

    Daniel Angulo

    Done

    Line 433, Patchset 9: pseudo_tcp_.NotifyPacket(UNSAFE_BUFFERS(
    Arthur Sonzogni . resolved

    Ditto

    Daniel Angulo

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Arthur Sonzogni
    • Stephen Nusko
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Id1a0ff3462edd3d7fa119beff620570f1893a0d8
    Gerrit-Change-Number: 7526157
    Gerrit-PatchSet: 10
    Gerrit-Owner: Daniel Angulo <angd...@google.com>
    Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Reviewer: Daniel Angulo <angd...@google.com>
    Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
    Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
    Gerrit-Attention: Stephen Nusko <nus...@chromium.org>
    Gerrit-Attention: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Comment-Date: Fri, 13 Feb 2026 21:59:18 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Arthur Sonzogni <arthurs...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Daniel Angulo (Gerrit)

    unread,
    Feb 13, 2026, 5:01:46 PMFeb 13
    to Code Review Nudger, Arthur Sonzogni, Stephen Nusko, AyeAye, Chromium LUCI CQ, chromotin...@chromium.org
    Attention needed from Arthur Sonzogni and Stephen Nusko

    Daniel Angulo added 1 comment

    File remoting/protocol/pseudo_tcp.h
    Line 81, Patchset 9: bool NotifyPacket(base::span<const char> buffer);
    Arthur Sonzogni . unresolved

    Optional: Ma

    Daniel Angulo

    Ma?

    Daniel Angulo

    sorry, what did you say?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Arthur Sonzogni
    • Stephen Nusko
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Id1a0ff3462edd3d7fa119beff620570f1893a0d8
    Gerrit-Change-Number: 7526157
    Gerrit-PatchSet: 11
    Gerrit-Owner: Daniel Angulo <angd...@google.com>
    Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Reviewer: Daniel Angulo <angd...@google.com>
    Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
    Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
    Gerrit-Attention: Stephen Nusko <nus...@chromium.org>
    Gerrit-Attention: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Comment-Date: Fri, 13 Feb 2026 22:01:41 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Stephen Nusko (Gerrit)

    unread,
    Feb 15, 2026, 10:02:47 PMFeb 15
    to Daniel Angulo, Code Review Nudger, Arthur Sonzogni, AyeAye, Chromium LUCI CQ, chromotin...@chromium.org
    Attention needed from Arthur Sonzogni and Daniel Angulo

    Stephen Nusko added 9 comments

    File remoting/protocol/pseudo_tcp.h
    Line 123, Patchset 11 (Latest): base::raw_span<const uint8_t> data;
    Stephen Nusko . unresolved

    Do we know if there is any benchmarks around this code? This is the line most likely to trigger potential performance impact as we create and destroy segments.

    File remoting/protocol/pseudo_tcp.cc
    Line 99, Patchset 11 (Latest): void WriteString(const char* str, size_t len) {

    // SAFETY: `str` is a raw char*, but we immediately convert it to a span of
    // bytes, which makes our intentions clear and prevents buffer overflows.
    auto bytes = base::as_byte_span(UNSAFE_BUFFERS(base::span(str, len)));
    Stephen Nusko . unresolved

    There is no caller of this function? Lets just switch it to a span? or delete it.

    Line 124, Patchset 11 (Latest): *val = base::U32FromBigEndian(data_.subspan(pos_).first<4u>());
    Stephen Nusko . unresolved

    Should we continue to use base::NetToHost32? Here and below to keep the convention?

    Line 137, Patchset 2: base::as_writable_bytes(UNSAFE_BUFFERS(base::span(str, len)))
    Stephen Nusko . resolved

    We can't claim UNSAFE_BUFFERS here, what SAFETY message would you write?

    We have 3 options
    1) Make this function take std::string_view
    2) Make this function UNSAFE_BUFFER_USAGE and force all callers to add UNSAFE_TODO or UNSAFE_BUFFERS
    3) Mark this as UNSAFE_TODO for now until someone can do 1 or 2.

    Daniel Angulo

    I was thinking that string_view can't be used because it needs to write data on it, but making this function take a span<char> would work instead. However this function is not used anywhare, should I stray it?

    Stephen Nusko

    If this function isn't used we should just delete it I think?

    I guess the API it is copied from has one, so we could keep it.

    Also I think std::string_view is fine? we are writing a string so accepting a string and converting it to bytes seems fine?

    Daniel Angulo

    isn't it writing data+pos into the same str that is the parameter?

    Stephen Nusko

    Obviously a char span works, but an std::string_view can be converted to a span cheaply so I'm not sure I follow the concern?

    Since you already have to do base::as_writable_byte_span there is no difference but API clarity that you have a string? So better to use an std::string_view no?

    Daniel Angulo

    base::as_writable_byte_span cannot be used with a std::string_view. Here's why

    std::string_view is Read-Only: A std::string_view (and absl::string_view) provides a non-owning, read-only view into an existing character sequence. It doesn't own the data and cannot be used to modify it.

    Stephen Nusko

    Ah right makes sense.

    Line 590, Patchset 6: base::span<uint8_t> buffer(buffer_storage);
    Stephen Nusko . resolved

    You don't need this variable, just pass `buffer_storage` directly into the SpanWriter.

    And use the `subspan` method on `buffer_storage` directly for ReadOffset call.

    Daniel Angulo
    no viable constructor or deduction guide for deduction of template arguments of 'base::SpanWriter'
    589 | base::SpanWriter writer(buffer_storage);
    Stephen Nusko

    I still prefer colapsing this to a single line:

    ```
    base::SpanWriter writer(base::span(buffer_storage));
    ```

    Also I think you might be able to do it with a template specification.

    ```
    base::SpanWriter<uint8_t> writer(buffer_storage);
    ```

    Which should remove one layer of guess work for the compiler.

    Both seem more readable to me then a variable we don't use again

    Line 652, Patchset 5: reader.Skip(1u);
    Stephen Nusko . unresolved

    What is this skip? isn't flags at position 13?

    `ack` = `buffer + 8` which is U32 so 4 bytes so ends at `buffer + 12`, and then we do `seq.flags = buffer[13]`; but in the new code we `Skip(1u)`?

    Daniel Angulo

    in the writter we have buff[12] = 0; (which is the position 13) then buff[13] = flags (which is position 14). If I disable the skip then a bunch of tests start to fail

    Stephen Nusko

    Perfect can you add a comment mentioning this? Makes sense.

    Daniel Angulo

    Done

    Stephen Nusko

    I'm sorry I don't see the comment?

    Just something like.

    ```
    reader.Skip(1u); // Skip the zero byte.
    ```
    Line 1385, Patchset 5: const size_t tail_copy = std::min(copy, buffer_.size() - read_position_);

    new_buffer.subspan(0, tail_copy)
    .copy_from(buffer_.subspan(read_position_, tail_copy));
    new_buffer.subspan(tail_copy, copy - tail_copy)
    .copy_from(buffer_.subspan(0, copy - tail_copy));
    Stephen Nusko . unresolved

    could this be written as a base::span::split? I think so?

    Daniel Angulo

    Done

    Daniel Angulo

    how? I see that there could be a split at tail_copy, but buffer_.subspan(0, copy - tail_copy) starts at offset 0 not at tail_copy, maybe I'm just a little bit confused but I don't see a clean split

    Stephen Nusko

    I like this already better because the copy is clear what is going into what. But I think we can do the other as well.


    ```
    auto new_buffer = base::HeapArray<uint8_t>::WithSize(size);

    const size_t copy = data_length_;

    const size_t tail_copy = std::min(copy, buffer_.size() - read_position_);

        // Split `new_buffer` into |:tail_copy:|:copy - tail_copy:| spans.
    auto [new_buffer_first, new_buffer_last] =
    new_buffer.as_span().first(copy).split_at(tail_copy);
    // Split `buffer` into | buffer_.size() - read_position | read_position |
    auto [before_read, after_read_position] =
    buffer_.as_span().split_at(read_position_);
    // Note: size > data_length_, but buffer_.size() >= data_length_ and unknown relation to size.
    // Any value after read_position_ is the |tail_copy|, but before_read
    // could be larger then the remaining |tail_copy - copy| so we adjust
    // it to make them equal (old_buffer_end might be empty).
    CHECK_EQ(old_buffer_start.size(), tail_copy);
    old_buffer_end = old_buffer_end.first(tail_copy-copy);

    new_buffer_first.copy_from_nonoverlapping(old_buffer_start);
    new_buffer_last.copy_from_nonoverlapping(old_buffer_end);
    ```

    Or something like that?

    File remoting/protocol/pseudo_tcp_unittest.cc
    Line 373, Patchset 11 (Latest): size_t tosend = std::min(static_cast<size_t>(kBlockSize),
    send_buffer_.size() - send_stream_pos_);
    if (tosend > 0) {
    base::span(block).first(tosend).copy_from(base::as_bytes(
    base::span(send_buffer_).subspan(send_stream_pos_, tosend)));
    sent = local_.Send(base::span(block).first(tosend));
    Stephen Nusko . unresolved

    We do this twice? and we never use "tosend" again. Perhaps rename it into a span and use it directly?

    ```suggestion
    auto tosend = base::span(block).first(
    std::min(static_cast<size_t>(kBlockSize),
    send_buffer_.size() - send_stream_pos_));
    if (!tosend.empty()) {
    tosend.copy_from(base::as_bytes(
    base::span(send_buffer_).subspan(send_stream_pos_, tosend.size())));
    sent = local_.Send(tosend);
    ```

    And consider this down below in other spots where it gets reused repeatedly?

    File remoting/protocol/pseudotcp_adapter.cc
    Line 156, Patchset 8: int buffer_size,
    Arthur Sonzogni . unresolved

    Can we `CHECK_EQ(buffer->span().size(), buffer_size)`.

    Eventually, the `buffer_size` argument would be removed, but this is going to take additional refactoring.

    Daniel Angulo

    check_eq is throwing error because buffer->span() and buffer_size are not equal, have just added .first(buffer_size) to the Recv call

    Stephen Nusko

    Are there a lot of calls to it? Can we add the .first() to the callers of Read/Write? As Arthur said eventually we'd like to get rid of these, but if there are a lot of callers this might need to be an eventual cleanup.

    It looks like each PseudoTcpAdapter::Core is only called from one spot, so could we just remove it and move the .first() into the PseudoTcpAdapter::Read/Write? although it also appears they are only called in a couple locations (like 4 files or so each), so we could move the .first() even higher there.

    If you'd like to keep the CL from exploding could we at least add the CHECK arthur requested here, and update PseudoTcpAdapter::Read/Write to call .first() there? And then as a follow up you could propagate it up one level to the 4-8 files.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Arthur Sonzogni
    • Daniel Angulo
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Id1a0ff3462edd3d7fa119beff620570f1893a0d8
    Gerrit-Change-Number: 7526157
    Gerrit-PatchSet: 11
    Gerrit-Owner: Daniel Angulo <angd...@google.com>
    Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Reviewer: Daniel Angulo <angd...@google.com>
    Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
    Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
    Gerrit-Attention: Daniel Angulo <angd...@google.com>
    Gerrit-Attention: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Comment-Date: Mon, 16 Feb 2026 03:02:24 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Stephen Nusko <nus...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Arthur Sonzogni (Gerrit)

    unread,
    Feb 16, 2026, 8:36:38 AMFeb 16
    to Daniel Angulo, Code Review Nudger, Stephen Nusko, AyeAye, Chromium LUCI CQ, chromotin...@chromium.org
    Attention needed from Daniel Angulo

    Arthur Sonzogni added 1 comment

    File remoting/protocol/pseudo_tcp.h
    Line 81, Patchset 9: bool NotifyPacket(base::span<const char> buffer);
    Arthur Sonzogni . unresolved

    Optional: Ma

    Daniel Angulo

    Ma?

    Daniel Angulo

    sorry, what did you say?

    Arthur Sonzogni

    Optional: Maybe this could be `“ase::span<const uint8_t>` directly. This would avoid conversion internally and avoid mixing the two types in this class.

    Of course, that would move the need to convert to the callers, but I think this is better.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Daniel Angulo
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Id1a0ff3462edd3d7fa119beff620570f1893a0d8
    Gerrit-Change-Number: 7526157
    Gerrit-PatchSet: 11
    Gerrit-Owner: Daniel Angulo <angd...@google.com>
    Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Reviewer: Daniel Angulo <angd...@google.com>
    Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
    Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
    Gerrit-Attention: Daniel Angulo <angd...@google.com>
    Gerrit-Comment-Date: Mon, 16 Feb 2026 13:36:22 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Daniel Angulo (Gerrit)

    unread,
    Feb 24, 2026, 4:53:00 PMFeb 24
    to Code Review Nudger, Arthur Sonzogni, Stephen Nusko, AyeAye, Chromium LUCI CQ, chromotin...@chromium.org
    Attention needed from Arthur Sonzogni and Stephen Nusko

    Daniel Angulo added 6 comments

    File remoting/protocol/pseudo_tcp.h
    Line 123, Patchset 11 (Latest): base::raw_span<const uint8_t> data;
    Stephen Nusko . unresolved

    Do we know if there is any benchmarks around this code? This is the line most likely to trigger potential performance impact as we create and destroy segments.

    Daniel Angulo

    found that the pseudo_tcp_unittest.cc file contains the core performance measurements, in TestTransfer method measures time of transfer. But didn't find a perftest.

    Line 81, Patchset 9: bool NotifyPacket(base::span<const char> buffer);
    Arthur Sonzogni . resolved

    Optional: Ma

    Daniel Angulo

    Ma?

    Daniel Angulo

    sorry, what did you say?

    Arthur Sonzogni

    Optional: Maybe this could be `“ase::span<const uint8_t>` directly. This would avoid conversion internally and avoid mixing the two types in this class.

    Of course, that would move the need to convert to the callers, but I think this is better.

    Daniel Angulo

    Done

    File remoting/protocol/pseudo_tcp.cc
    Line 652, Patchset 5: reader.Skip(1u);
    Stephen Nusko . resolved

    What is this skip? isn't flags at position 13?

    `ack` = `buffer + 8` which is U32 so 4 bytes so ends at `buffer + 12`, and then we do `seq.flags = buffer[13]`; but in the new code we `Skip(1u)`?

    Daniel Angulo

    in the writter we have buff[12] = 0; (which is the position 13) then buff[13] = flags (which is position 14). If I disable the skip then a bunch of tests start to fail

    Stephen Nusko

    Perfect can you add a comment mentioning this? Makes sense.

    Daniel Angulo

    Done

    Stephen Nusko

    I'm sorry I don't see the comment?

    Just something like.

    ```
    reader.Skip(1u); // Skip the zero byte.
    ```
    Daniel Angulo

    sorry my code editor reverted my comment without realizing.

    Line 1385, Patchset 5: const size_t tail_copy = std::min(copy, buffer_.size() - read_position_);

    new_buffer.subspan(0, tail_copy)
    .copy_from(buffer_.subspan(read_position_, tail_copy));
    new_buffer.subspan(tail_copy, copy - tail_copy)
    .copy_from(buffer_.subspan(0, copy - tail_copy));
    Stephen Nusko . resolved
    Daniel Angulo

    sounds good

    File remoting/protocol/pseudo_tcp_unittest.cc
    Line 373, Patchset 11 (Latest): size_t tosend = std::min(static_cast<size_t>(kBlockSize),
    send_buffer_.size() - send_stream_pos_);
    if (tosend > 0) {
    base::span(block).first(tosend).copy_from(base::as_bytes(
    base::span(send_buffer_).subspan(send_stream_pos_, tosend)));
    sent = local_.Send(base::span(block).first(tosend));
    Stephen Nusko . resolved

    We do this twice? and we never use "tosend" again. Perhaps rename it into a span and use it directly?

    ```suggestion
    auto tosend = base::span(block).first(
    std::min(static_cast<size_t>(kBlockSize),
    send_buffer_.size() - send_stream_pos_));
    if (!tosend.empty()) {
    tosend.copy_from(base::as_bytes(
    base::span(send_buffer_).subspan(send_stream_pos_, tosend.size())));
    sent = local_.Send(tosend);
    ```

    And consider this down below in other spots where it gets reused repeatedly?

    Daniel Angulo

    Done

    File remoting/protocol/pseudotcp_adapter.cc
    Line 156, Patchset 8: int buffer_size,
    Arthur Sonzogni . unresolved

    Can we `CHECK_EQ(buffer->span().size(), buffer_size)`.

    Eventually, the `buffer_size` argument would be removed, but this is going to take additional refactoring.

    Daniel Angulo

    check_eq is throwing error because buffer->span() and buffer_size are not equal, have just added .first(buffer_size) to the Recv call

    Stephen Nusko

    Are there a lot of calls to it? Can we add the .first() to the callers of Read/Write? As Arthur said eventually we'd like to get rid of these, but if there are a lot of callers this might need to be an eventual cleanup.

    It looks like each PseudoTcpAdapter::Core is only called from one spot, so could we just remove it and move the .first() into the PseudoTcpAdapter::Read/Write? although it also appears they are only called in a couple locations (like 4 files or so each), so we could move the .first() even higher there.

    If you'd like to keep the CL from exploding could we at least add the CHECK arthur requested here, and update PseudoTcpAdapter::Read/Write to call .first() there? And then as a follow up you could propagate it up one level to the 4-8 files.

    Daniel Angulo

    I'm not familiar with scoped_refptr yet, but I feel is not that simple to update PseudoTcpAdapter::Read/Write to call .first() there, the buffer parameter is a scoped_refptr<net::IOBuffer>& not a span (although it manages a span internally), it looks to be used in other places and I'm been cautious to alter the internal buffer->span() size. I was thinking on changing it to receive a span, but also see the call to reset() on the buffer which I'm not familiar of what it does but seems coupled to the original type.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Arthur Sonzogni
    • Stephen Nusko
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Id1a0ff3462edd3d7fa119beff620570f1893a0d8
    Gerrit-Change-Number: 7526157
    Gerrit-PatchSet: 11
    Gerrit-Owner: Daniel Angulo <angd...@google.com>
    Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Reviewer: Daniel Angulo <angd...@google.com>
    Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
    Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
    Gerrit-Attention: Stephen Nusko <nus...@chromium.org>
    Gerrit-Attention: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Comment-Date: Tue, 24 Feb 2026 21:52:55 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Stephen Nusko <nus...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Stephen Nusko (Gerrit)

    unread,
    Feb 24, 2026, 9:40:26 PMFeb 24
    to Daniel Angulo, Code Review Nudger, Arthur Sonzogni, AyeAye, Chromium LUCI CQ, chromotin...@chromium.org
    Attention needed from Arthur Sonzogni and Daniel Angulo

    Stephen Nusko added 1 comment

    File remoting/protocol/pseudo_tcp.h
    Line 123, Patchset 11 (Latest): base::raw_span<const uint8_t> data;
    Stephen Nusko . unresolved

    Do we know if there is any benchmarks around this code? This is the line most likely to trigger potential performance impact as we create and destroy segments.

    Daniel Angulo

    found that the pseudo_tcp_unittest.cc file contains the core performance measurements, in TestTransfer method measures time of transfer. But didn't find a perftest.

    Stephen Nusko

    This is only used in a single location (`bool process(Segment& seg)`)

    And that is only called with a reference (lifetime will always be valid)

    There isn't really a point having this be a raw_ptr.


    ```
    Pointers in local variables and function parameters and return values. This includes pointer fields in classes/structs that are used only on the stack. (Using raw_ptr<T> here would cumulatively lead to performance regression and the security benefit of UaF protection is lower for such short-lived pointers.)
    ```

    (from [here](https://chromium.googlesource.com/chromium/src/+/HEAD/base/memory/raw_ptr.md#pointers-in-locations-other-than-fields))

    So I would do the following:

    ```
    struct Segment {
    STACK_ALLOCATED();
    uint32_t conv, seq, ack;
    uint8_t flags;
    uint16_t wnd;
    // RAW_PTR_EXCLUSION: Stack-scoped
    RAW_PTR_EXCLUSION base::span<const uint8_t> data;
    ```

    Does that make sense? This ensures it is only ever used as stack allocated (which means the pointer has to be valid if it was valid to begin with and no one calls free).

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Arthur Sonzogni
    • Daniel Angulo
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Id1a0ff3462edd3d7fa119beff620570f1893a0d8
    Gerrit-Change-Number: 7526157
    Gerrit-PatchSet: 11
    Gerrit-Owner: Daniel Angulo <angd...@google.com>
    Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Reviewer: Daniel Angulo <angd...@google.com>
    Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
    Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
    Gerrit-Attention: Daniel Angulo <angd...@google.com>
    Gerrit-Attention: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Comment-Date: Wed, 25 Feb 2026 02:40:03 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Arthur Sonzogni (Gerrit)

    unread,
    Feb 25, 2026, 5:05:07 AMFeb 25
    to Daniel Angulo, Code Review Nudger, Stephen Nusko, AyeAye, Chromium LUCI CQ, chromotin...@chromium.org
    Attention needed from Daniel Angulo

    Arthur Sonzogni added 1 comment

    File remoting/protocol/pseudo_tcp.cc
    Line 99, Patchset 11 (Latest): void WriteString(const char* str, size_t len) {
    // SAFETY: `str` is a raw char*, but we immediately convert it to a span of
    // bytes, which makes our intentions clear and prevents buffer overflows.
    auto bytes = base::as_byte_span(UNSAFE_BUFFERS(base::span(str, len)));
    Stephen Nusko . unresolved

    There is no caller of this function? Lets just switch it to a span? or delete it.

    Arthur Sonzogni

    (waiting on this comment to be addressed)

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Daniel Angulo
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Id1a0ff3462edd3d7fa119beff620570f1893a0d8
    Gerrit-Change-Number: 7526157
    Gerrit-PatchSet: 11
    Gerrit-Owner: Daniel Angulo <angd...@google.com>
    Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
    Gerrit-Reviewer: Daniel Angulo <angd...@google.com>
    Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
    Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
    Gerrit-Attention: Daniel Angulo <angd...@google.com>
    Gerrit-Comment-Date: Wed, 25 Feb 2026 10:04:47 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Daniel Angulo (Gerrit)

    unread,
    Mar 3, 2026, 4:34:34 PM (11 days ago) Mar 3
    to Code Review Nudger, Arthur Sonzogni, Stephen Nusko, AyeAye, Chromium LUCI CQ, chromotin...@chromium.org
    Attention needed from Arthur Sonzogni and Stephen Nusko

    Daniel Angulo added 4 comments

    File remoting/protocol/pseudo_tcp.h
    Line 123, Patchset 11: base::raw_span<const uint8_t> data;
    Stephen Nusko . resolved

    Do we know if there is any benchmarks around this code? This is the line most likely to trigger potential performance impact as we create and destroy segments.

    Daniel Angulo

    found that the pseudo_tcp_unittest.cc file contains the core performance measurements, in TestTransfer method measures time of transfer. But didn't find a perftest.

    Stephen Nusko

    This is only used in a single location (`bool process(Segment& seg)`)

    And that is only called with a reference (lifetime will always be valid)

    There isn't really a point having this be a raw_ptr.


    ```
    Pointers in local variables and function parameters and return values. This includes pointer fields in classes/structs that are used only on the stack. (Using raw_ptr<T> here would cumulatively lead to performance regression and the security benefit of UaF protection is lower for such short-lived pointers.)
    ```

    (from [here](https://chromium.googlesource.com/chromium/src/+/HEAD/base/memory/raw_ptr.md#pointers-in-locations-other-than-fields))

    So I would do the following:

    ```
    struct Segment {
    STACK_ALLOCATED();
    uint32_t conv, seq, ack;
    uint8_t flags;
    uint16_t wnd;
    // RAW_PTR_EXCLUSION: Stack-scoped
    RAW_PTR_EXCLUSION base::span<const uint8_t> data;
    ```

    Does that make sense? This ensures it is only ever used as stack allocated (which means the pointer has to be valid if it was valid to begin with and no one calls free).

    Daniel Angulo

    makes sense!

    File remoting/protocol/pseudo_tcp.cc
    Line 99, Patchset 11: void WriteString(const char* str, size_t len) {

    // SAFETY: `str` is a raw char*, but we immediately convert it to a span of
    // bytes, which makes our intentions clear and prevents buffer overflows.
    auto bytes = base::as_byte_span(UNSAFE_BUFFERS(base::span(str, len)));
    Stephen Nusko . resolved

    There is no caller of this function? Lets just switch it to a span? or delete it.

    Arthur Sonzogni

    (waiting on this comment to be addressed)

    Daniel Angulo

    Done

    Line 124, Patchset 11: *val = base::U32FromBigEndian(data_.subspan(pos_).first<4u>());
    Stephen Nusko . resolved

    Should we continue to use base::NetToHost32? Here and below to keep the convention?

    Daniel Angulo

    sure

    File remoting/protocol/pseudotcp_adapter.cc
    Line 156, Patchset 8: int buffer_size,
    Arthur Sonzogni . resolved

    Can we `CHECK_EQ(buffer->span().size(), buffer_size)`.

    Eventually, the `buffer_size` argument would be removed, but this is going to take additional refactoring.

    Daniel Angulo

    check_eq is throwing error because buffer->span() and buffer_size are not equal, have just added .first(buffer_size) to the Recv call

    Stephen Nusko

    Are there a lot of calls to it? Can we add the .first() to the callers of Read/Write? As Arthur said eventually we'd like to get rid of these, but if there are a lot of callers this might need to be an eventual cleanup.

    It looks like each PseudoTcpAdapter::Core is only called from one spot, so could we just remove it and move the .first() into the PseudoTcpAdapter::Read/Write? although it also appears they are only called in a couple locations (like 4 files or so each), so we could move the .first() even higher there.

    If you'd like to keep the CL from exploding could we at least add the CHECK arthur requested here, and update PseudoTcpAdapter::Read/Write to call .first() there? And then as a follow up you could propagate it up one level to the 4-8 files.

    Daniel Angulo

    I'm not familiar with scoped_refptr yet, but I feel is not that simple to update PseudoTcpAdapter::Read/Write to call .first() there, the buffer parameter is a scoped_refptr<net::IOBuffer>& not a span (although it manages a span internally), it looks to be used in other places and I'm been cautious to alter the internal buffer->span() size. I was thinking on changing it to receive a span, but also see the call to reset() on the buffer which I'm not familiar of what it does but seems coupled to the original type.

    Daniel Angulo

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Arthur Sonzogni
    • Stephen Nusko
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: Id1a0ff3462edd3d7fa119beff620570f1893a0d8
      Gerrit-Change-Number: 7526157
      Gerrit-PatchSet: 13
      Gerrit-Owner: Daniel Angulo <angd...@google.com>
      Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
      Gerrit-Reviewer: Daniel Angulo <angd...@google.com>
      Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
      Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
      Gerrit-Attention: Stephen Nusko <nus...@chromium.org>
      Gerrit-Attention: Arthur Sonzogni <arthurs...@chromium.org>
      Gerrit-Comment-Date: Tue, 03 Mar 2026 21:34:28 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Stephen Nusko <nus...@chromium.org>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Stephen Nusko (Gerrit)

      unread,
      Mar 4, 2026, 12:28:11 AM (11 days ago) Mar 4
      to Daniel Angulo, Code Review Nudger, Arthur Sonzogni, AyeAye, Chromium LUCI CQ, chromotin...@chromium.org
      Attention needed from Arthur Sonzogni and Daniel Angulo

      Stephen Nusko added 8 comments

      File remoting/protocol/pseudo_tcp.h
      Line 125, Patchset 14 (Latest): STACK_ALLOCATED();
      Stephen Nusko . unresolved

      nit: STACK_ALLOCATED() is by convention at the top even above the `public:`

      Line 118, Patchset 14 (Latest): public:
      Stephen Nusko . unresolved

      Segment is a struct everything is public by default, you can remove.

      File remoting/protocol/pseudo_tcp.cc
      Line 102, Patchset 14 (Latest): // Added methods for base::span support
      uint8_t* begin() { return data_.data(); }
      const uint8_t* begin() const { return data_.data(); }
      uint8_t* end() { return UNSAFE_TODO(data_.data() + data_.size()); }
      const uint8_t* end() const {
      return UNSAFE_TODO(data_.data() + data_.size());
      }
      Stephen Nusko . unresolved

      What is this for? I see the comment but I don't understand it?

      1) Why would we need iterator type methods to support base::span?
      2) data_ is a vector we can just return their iterators if needed .begin()/end()?

      Line 119, Patchset 14 (Latest): *reinterpret_cast<const uint32_t*>(data_.subspan(pos_).data()));
      Stephen Nusko . unresolved

      nit: `base::NetToHost32(base::U32FromNativeEndian(data_.subspan(pos_, sizeof(uint32_t))))`

      here and below

      Line 143, Patchset 14 (Latest): base::as_writable_byte_span(str).copy_from(data_.subspan(pos_, str.size()));
      Stephen Nusko . unresolved

      This is already a span? I don't think we need a span to a span,

      just use

      `as_writable_bytes(str)`

      Line 622, Patchset 14 (Latest): this, reinterpret_cast<char*>(buffer_storage.data()), len + HEADER_SIZE);
      Stephen Nusko . unresolved

      `base::as_writable_chars(buffer_storage).data()`

      Line 1393, Patchset 14 (Latest): // Note: size > data_length_, but buffer_.size() >= data_length_ and unknown
      Stephen Nusko . unresolved

      nit: `>=`

      we only checked data_length_ > size which implies data_length_ <= size, and thus size is >= data_length

      File remoting/protocol/pseudo_tcp_unittest.cc
      Line 197, Patchset 14 (Latest): other->NotifyPacket(base::as_byte_span(std::string_view(packet)));
      Stephen Nusko . unresolved

      Again do we want a span to the string_view? I think we just want to convert it to uint8_t?

      use `base::as_bytes`

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Arthur Sonzogni
      • Daniel Angulo
      Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Owners
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: Id1a0ff3462edd3d7fa119beff620570f1893a0d8
        Gerrit-Change-Number: 7526157
        Gerrit-PatchSet: 14
        Gerrit-Owner: Daniel Angulo <angd...@google.com>
        Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
        Gerrit-Reviewer: Daniel Angulo <angd...@google.com>
        Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
        Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
        Gerrit-Attention: Daniel Angulo <angd...@google.com>
        Gerrit-Attention: Arthur Sonzogni <arthurs...@chromium.org>
        Gerrit-Comment-Date: Wed, 04 Mar 2026 05:27:50 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Daniel Angulo (Gerrit)

        unread,
        Mar 4, 2026, 11:02:53 AM (10 days ago) Mar 4
        to Code Review Nudger, Arthur Sonzogni, Stephen Nusko, AyeAye, Chromium LUCI CQ, chromotin...@chromium.org
        Attention needed from Arthur Sonzogni and Stephen Nusko

        Daniel Angulo added 3 comments

        File remoting/protocol/pseudo_tcp.h
        Stephen Nusko . unresolved

        nit: STACK_ALLOCATED() is by convention at the top even above the `public:`

        Daniel Angulo

        STACK_ALLOCATED macro has a private keyword at the begining, so if it is on placed on top all the members that follow will be private. I found moving it to the bottom a nice solution for this.

        Stephen Nusko . unresolved

        Segment is a struct everything is public by default, you can remove.

        Daniel Angulo

        STACK_ALLOCATED macro is converting everything that follows to private, maybe I can remove this one, but only if it is on the bottom.

        File remoting/protocol/pseudo_tcp.cc
        Line 102, Patchset 14 (Latest): // Added methods for base::span support
        uint8_t* begin() { return data_.data(); }
        const uint8_t* begin() const { return data_.data(); }
        uint8_t* end() { return UNSAFE_TODO(data_.data() + data_.size()); }
        const uint8_t* end() const {
        return UNSAFE_TODO(data_.data() + data_.size());
        }
        Stephen Nusko . unresolved

        What is this for? I see the comment but I don't understand it?

        1) Why would we need iterator type methods to support base::span?
        2) data_ is a vector we can just return their iterators if needed .begin()/end()?

        Daniel Angulo

        Compiler was complaining that this class can't be implicitly converted to a span, I had to add those methods to make it compatible with spans.

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Arthur Sonzogni
        • Stephen Nusko
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Owners
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: Id1a0ff3462edd3d7fa119beff620570f1893a0d8
        Gerrit-Change-Number: 7526157
        Gerrit-PatchSet: 14
        Gerrit-Owner: Daniel Angulo <angd...@google.com>
        Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
        Gerrit-Reviewer: Daniel Angulo <angd...@google.com>
        Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
        Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
        Gerrit-Attention: Stephen Nusko <nus...@chromium.org>
        Gerrit-Attention: Arthur Sonzogni <arthurs...@chromium.org>
        Gerrit-Comment-Date: Wed, 04 Mar 2026 16:02:45 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: Stephen Nusko <nus...@chromium.org>
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Daniel Angulo (Gerrit)

        unread,
        Mar 4, 2026, 11:48:43 AM (10 days ago) Mar 4
        to Code Review Nudger, Arthur Sonzogni, Stephen Nusko, AyeAye, Chromium LUCI CQ, chromotin...@chromium.org
        Attention needed from Arthur Sonzogni and Stephen Nusko

        Daniel Angulo added 5 comments

        File remoting/protocol/pseudo_tcp.cc
        Line 119, Patchset 14: *reinterpret_cast<const uint32_t*>(data_.subspan(pos_).data()));
        Stephen Nusko . unresolved

        nit: `base::NetToHost32(base::U32FromNativeEndian(data_.subspan(pos_, sizeof(uint32_t))))`

        here and below

        Daniel Angulo

        I tryed that but I get: no viable conversion from 'span<element_type>' (aka 'span<const unsigned char>') to 'std::span<const uint8_t, 4U>'.

        uint8_t and char are not interchangable.

        Line 143, Patchset 14: base::as_writable_byte_span(str).copy_from(data_.subspan(pos_, str.size()));
        Stephen Nusko . resolved

        This is already a span? I don't think we need a span to a span,

        just use

        `as_writable_bytes(str)`

        Daniel Angulo

        Done

        Line 622, Patchset 14: this, reinterpret_cast<char*>(buffer_storage.data()), len + HEADER_SIZE);
        Stephen Nusko . resolved

        `base::as_writable_chars(buffer_storage).data()`

        Daniel Angulo

        Done

        Line 1393, Patchset 14: // Note: size > data_length_, but buffer_.size() >= data_length_ and unknown
        Stephen Nusko . resolved

        nit: `>=`

        we only checked data_length_ > size which implies data_length_ <= size, and thus size is >= data_length

        Daniel Angulo

        Done

        File remoting/protocol/pseudo_tcp_unittest.cc
        Line 197, Patchset 14: other->NotifyPacket(base::as_byte_span(std::string_view(packet)));
        Stephen Nusko . unresolved

        Again do we want a span to the string_view? I think we just want to convert it to uint8_t?

        use `base::as_bytes`

        Daniel Angulo

        error: no matching function for call to 'as_bytes', candidate template ignored: could not match 'span' against 'basic_string_view'

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Arthur Sonzogni
        • Stephen Nusko
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Owners
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: Id1a0ff3462edd3d7fa119beff620570f1893a0d8
        Gerrit-Change-Number: 7526157
        Gerrit-PatchSet: 15
        Gerrit-Owner: Daniel Angulo <angd...@google.com>
        Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
        Gerrit-Reviewer: Daniel Angulo <angd...@google.com>
        Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
        Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
        Gerrit-Attention: Stephen Nusko <nus...@chromium.org>
        Gerrit-Attention: Arthur Sonzogni <arthurs...@chromium.org>
        Gerrit-Comment-Date: Wed, 04 Mar 2026 16:48:36 +0000
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Arthur Sonzogni (Gerrit)

        unread,
        Mar 4, 2026, 12:41:41 PM (10 days ago) Mar 4
        to Daniel Angulo, Code Review Nudger, Stephen Nusko, AyeAye, Chromium LUCI CQ, chromotin...@chromium.org
        Attention needed from Daniel Angulo and Stephen Nusko

        Arthur Sonzogni added 1 comment

        File remoting/protocol/pseudo_tcp.h
        Line 125, Patchset 14: STACK_ALLOCATED();
        Stephen Nusko . unresolved

        nit: STACK_ALLOCATED() is by convention at the top even above the `public:`

        Daniel Angulo

        STACK_ALLOCATED macro has a private keyword at the begining, so if it is on placed on top all the members that follow will be private. I found moving it to the bottom a nice solution for this.

        Arthur Sonzogni
        Daniel, what about putting it at the top and  then adding "public:" below to keep the members public?
        ```
        STACK_ALLOCATED()

        public:
        ```
        Open in Gerrit

        Related details

        Attention is currently required from:
        • Daniel Angulo
        • Stephen Nusko
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Owners
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: Id1a0ff3462edd3d7fa119beff620570f1893a0d8
        Gerrit-Change-Number: 7526157
        Gerrit-PatchSet: 15
        Gerrit-Owner: Daniel Angulo <angd...@google.com>
        Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
        Gerrit-Reviewer: Daniel Angulo <angd...@google.com>
        Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
        Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
        Gerrit-Attention: Stephen Nusko <nus...@chromium.org>
        Gerrit-Attention: Daniel Angulo <angd...@google.com>
        Gerrit-Comment-Date: Wed, 04 Mar 2026 17:41:23 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: Stephen Nusko <nus...@chromium.org>
        Comment-In-Reply-To: Daniel Angulo <angd...@google.com>
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Daniel Angulo (Gerrit)

        unread,
        Mar 4, 2026, 4:30:04 PM (10 days ago) Mar 4
        to Code Review Nudger, Arthur Sonzogni, Stephen Nusko, AyeAye, Chromium LUCI CQ, chromotin...@chromium.org
        Attention needed from Arthur Sonzogni and Stephen Nusko

        Daniel Angulo added 2 comments

        File remoting/protocol/pseudo_tcp.h
        Line 125, Patchset 14: STACK_ALLOCATED();
        Stephen Nusko . resolved

        nit: STACK_ALLOCATED() is by convention at the top even above the `public:`

        Daniel Angulo

        STACK_ALLOCATED macro has a private keyword at the begining, so if it is on placed on top all the members that follow will be private. I found moving it to the bottom a nice solution for this.

        Arthur Sonzogni
        Daniel, what about putting it at the top and  then adding "public:" below to keep the members public?
        ```
        STACK_ALLOCATED()

        public:
        ```
        Daniel Angulo

        done

        Line 118, Patchset 14: public:
        Stephen Nusko . resolved

        Segment is a struct everything is public by default, you can remove.

        Daniel Angulo

        STACK_ALLOCATED macro is converting everything that follows to private, maybe I can remove this one, but only if it is on the bottom.

        Daniel Angulo

        Done

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Arthur Sonzogni
        • Stephen Nusko
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Owners
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: Id1a0ff3462edd3d7fa119beff620570f1893a0d8
        Gerrit-Change-Number: 7526157
        Gerrit-PatchSet: 16
        Gerrit-Owner: Daniel Angulo <angd...@google.com>
        Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
        Gerrit-Reviewer: Daniel Angulo <angd...@google.com>
        Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
        Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
        Gerrit-Attention: Stephen Nusko <nus...@chromium.org>
        Gerrit-Attention: Arthur Sonzogni <arthurs...@chromium.org>
        Gerrit-Comment-Date: Wed, 04 Mar 2026 21:29:56 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: Stephen Nusko <nus...@chromium.org>
        Comment-In-Reply-To: Daniel Angulo <angd...@google.com>
        Comment-In-Reply-To: Arthur Sonzogni <arthurs...@chromium.org>
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Stephen Nusko (Gerrit)

        unread,
        Mar 5, 2026, 1:37:48 AM (10 days ago) Mar 5
        to Daniel Angulo, Code Review Nudger, Arthur Sonzogni, AyeAye, Chromium LUCI CQ, chromotin...@chromium.org
        Attention needed from Arthur Sonzogni and Daniel Angulo

        Stephen Nusko added 3 comments

        File remoting/protocol/pseudo_tcp.cc
        Line 102, Patchset 14: // Added methods for base::span support

        uint8_t* begin() { return data_.data(); }
        const uint8_t* begin() const { return data_.data(); }
        uint8_t* end() { return UNSAFE_TODO(data_.data() + data_.size()); }
        const uint8_t* end() const {
        return UNSAFE_TODO(data_.data() + data_.size());
        }
        Stephen Nusko . unresolved

        What is this for? I see the comment but I don't understand it?

        1) Why would we need iterator type methods to support base::span?
        2) data_ is a vector we can just return their iterators if needed .begin()/end()?

        Daniel Angulo

        Compiler was complaining that this class can't be implicitly converted to a span, I had to add those methods to make it compatible with spans.

        Stephen Nusko

        Yes it isn't, but this isn't the best way to make it so. Spans just need a .data() and .size() method and that is safer (no UNSAFE_TODO for example).

        Can you either

        1) rename `Data()` to `data() and `Length()` to `size()`
        2) just add a `data()` and `size()` to make it convertable to span.

        Line 119, Patchset 14: *reinterpret_cast<const uint32_t*>(data_.subspan(pos_).data()));
        Stephen Nusko . unresolved

        nit: `base::NetToHost32(base::U32FromNativeEndian(data_.subspan(pos_, sizeof(uint32_t))))`

        here and below

        Daniel Angulo

        I tryed that but I get: no viable conversion from 'span<element_type>' (aka 'span<const unsigned char>') to 'std::span<const uint8_t, 4U>'.

        uint8_t and char are not interchangable.

        Stephen Nusko

        This is a fixable error though in both regards.

        ```
        auto bytes = base::as_bytes(data_.subspan(pos_, sizeof(uint32_t))).to_fixed_extent<sizeof(uint32_t)>();`
        *val = base::NetToHost32(base::u32FromNativeEndian(bytes));
        ```

        It is always possible to get to a fixed size if you know your span is the correct size (we subspan'd it just there).

        But also if you do the `base::as_bytes` to get ride of the unsigned char to uint8_t mismatch I think the compiler might have figured out to call .to_fixed_extent for you. Can you try?

        File remoting/protocol/pseudo_tcp_unittest.cc
        Line 197, Patchset 14: other->NotifyPacket(base::as_byte_span(std::string_view(packet)));
        Stephen Nusko . unresolved

        Again do we want a span to the string_view? I think we just want to convert it to uint8_t?

        use `base::as_bytes`

        Daniel Angulo

        error: no matching function for call to 'as_bytes', candidate template ignored: could not match 'span' against 'basic_string_view'

        Stephen Nusko

        Actually taking a step back we have a string that we want to be bytes.

        Shouldn't we just go

        ```
        base::as_byte_span(packet)
        ```

        No need for the string_view at all?

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Arthur Sonzogni
        • Daniel Angulo
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Owners
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: Id1a0ff3462edd3d7fa119beff620570f1893a0d8
        Gerrit-Change-Number: 7526157
        Gerrit-PatchSet: 16
        Gerrit-Owner: Daniel Angulo <angd...@google.com>
        Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
        Gerrit-Reviewer: Daniel Angulo <angd...@google.com>
        Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
        Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
        Gerrit-Attention: Daniel Angulo <angd...@google.com>
        Gerrit-Attention: Arthur Sonzogni <arthurs...@chromium.org>
        Gerrit-Comment-Date: Thu, 05 Mar 2026 06:37:16 +0000
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Daniel Angulo (Gerrit)

        unread,
        Mar 5, 2026, 12:25:12 PM (9 days ago) Mar 5
        to Code Review Nudger, Arthur Sonzogni, Stephen Nusko, AyeAye, Chromium LUCI CQ, chromotin...@chromium.org
        Attention needed from Arthur Sonzogni and Stephen Nusko

        Daniel Angulo added 3 comments

        File remoting/protocol/pseudo_tcp.cc
        Line 102, Patchset 14: // Added methods for base::span support
        uint8_t* begin() { return data_.data(); }
        const uint8_t* begin() const { return data_.data(); }
        uint8_t* end() { return UNSAFE_TODO(data_.data() + data_.size()); }
        const uint8_t* end() const {
        return UNSAFE_TODO(data_.data() + data_.size());
        }
        Stephen Nusko . unresolved

        What is this for? I see the comment but I don't understand it?

        1) Why would we need iterator type methods to support base::span?
        2) data_ is a vector we can just return their iterators if needed .begin()/end()?

        Daniel Angulo

        Compiler was complaining that this class can't be implicitly converted to a span, I had to add those methods to make it compatible with spans.

        Stephen Nusko

        Yes it isn't, but this isn't the best way to make it so. Spans just need a .data() and .size() method and that is safer (no UNSAFE_TODO for example).

        Can you either

        1) rename `Data()` to `data() and `Length()` to `size()`
        2) just add a `data()` and `size()` to make it convertable to span.

        Daniel Angulo

        adding data() and size() seems insufficient, I get this error: no viable constructor or deduction guide for deduction of template arguments of 'base::span'. candidate template ignored: couldn't infer template argument 'ElementType'. note: candidate template ignored: couldn't infer template argument 'ElementType'. candidate template ignored: constraints not satisfied [with R = ByteBufferWriter &] because 'ByteBufferWriter &' does not satisfy 'contiguous_range'

        Line 119, Patchset 14: *reinterpret_cast<const uint32_t*>(data_.subspan(pos_).data()));
        Stephen Nusko . resolved

        nit: `base::NetToHost32(base::U32FromNativeEndian(data_.subspan(pos_, sizeof(uint32_t))))`

        here and below

        Daniel Angulo

        I tryed that but I get: no viable conversion from 'span<element_type>' (aka 'span<const unsigned char>') to 'std::span<const uint8_t, 4U>'.

        uint8_t and char are not interchangable.

        Stephen Nusko

        This is a fixable error though in both regards.

        ```
        auto bytes = base::as_bytes(data_.subspan(pos_, sizeof(uint32_t))).to_fixed_extent<sizeof(uint32_t)>();`
        *val = base::NetToHost32(base::u32FromNativeEndian(bytes));
        ```

        It is always possible to get to a fixed size if you know your span is the correct size (we subspan'd it just there).

        But also if you do the `base::as_bytes` to get ride of the unsigned char to uint8_t mismatch I think the compiler might have figured out to call .to_fixed_extent for you. Can you try?

        Daniel Angulo

        Done

        File remoting/protocol/pseudo_tcp_unittest.cc
        Line 197, Patchset 14: other->NotifyPacket(base::as_byte_span(std::string_view(packet)));
        Stephen Nusko . resolved

        Again do we want a span to the string_view? I think we just want to convert it to uint8_t?

        use `base::as_bytes`

        Daniel Angulo

        error: no matching function for call to 'as_bytes', candidate template ignored: could not match 'span' against 'basic_string_view'

        Stephen Nusko

        Actually taking a step back we have a string that we want to be bytes.

        Shouldn't we just go

        ```
        base::as_byte_span(packet)
        ```

        No need for the string_view at all?

        Daniel Angulo

        Done

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Arthur Sonzogni
        • Stephen Nusko
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Owners
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: Id1a0ff3462edd3d7fa119beff620570f1893a0d8
        Gerrit-Change-Number: 7526157
        Gerrit-PatchSet: 17
        Gerrit-Owner: Daniel Angulo <angd...@google.com>
        Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
        Gerrit-Reviewer: Daniel Angulo <angd...@google.com>
        Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
        Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
        Gerrit-Attention: Stephen Nusko <nus...@chromium.org>
        Gerrit-Attention: Arthur Sonzogni <arthurs...@chromium.org>
        Gerrit-Comment-Date: Thu, 05 Mar 2026 17:25:00 +0000
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Arthur Sonzogni (Gerrit)

        unread,
        Mar 6, 2026, 11:09:44 AM (8 days ago) Mar 6
        to Daniel Angulo, Code Review Nudger, Stephen Nusko, AyeAye, Chromium LUCI CQ, chromotin...@chromium.org
        Attention needed from Daniel Angulo and Stephen Nusko

        Arthur Sonzogni added 2 comments

        Commit Message
        Line 1, Patchset 17 (Latest):Parent: 56633fc2 (Replace WIDGET_OWNS_NATIVE_WIDGET with CLIENT_OWNS_WIDGET in chrome/browser/preloading/preview)
        Arthur Sonzogni . unresolved

        Hey Daniel!

        Could you please try to compile your patches locally before requesting a code review? This would shorten the time to submit a patch, because you will be able to fix the issue before waiting on the code review.

        You can also wait on the `git cl try` run to finish.

        ---

        I fetched the patch locally and got:
        ```
        ../../remoting/protocol/pseudo_tcp.cc:121:56: error: no viable conversion from 'std::optional<span<element_type, 4UL>>' (aka 'std::optional<span<const unsigned char, 4UL>>') to 'std::span<const uint8_t, 4U>' (aka 'std::span<const unsigned char, 4U>')
        121 | *val = base::NetToHost32(base::U32FromNativeEndian(bytes));
        | ^~~~~

        ```

        File remoting/protocol/pseudo_tcp.h
        Line 124, Patchset 17 (Latest): // RAW_PTR_EXCLUSION: Stack-scoped

        RAW_PTR_EXCLUSION base::span<const uint8_t> data;
        Attention is currently required from:
        • Daniel Angulo
        • Stephen Nusko
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Owners
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: Id1a0ff3462edd3d7fa119beff620570f1893a0d8
        Gerrit-Change-Number: 7526157
        Gerrit-PatchSet: 17
        Gerrit-Owner: Daniel Angulo <angd...@google.com>
        Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
        Gerrit-Reviewer: Daniel Angulo <angd...@google.com>
        Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
        Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
        Gerrit-Attention: Stephen Nusko <nus...@chromium.org>
        Gerrit-Attention: Daniel Angulo <angd...@google.com>
        Gerrit-Comment-Date: Fri, 06 Mar 2026 16:09:28 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Stephen Nusko (Gerrit)

        unread,
        Mar 9, 2026, 3:49:32 AM (6 days ago) Mar 9
        to Daniel Angulo, Arthur Sonzogni, Code Review Nudger, AyeAye, Chromium LUCI CQ, chromotin...@chromium.org
        Attention needed from Arthur Sonzogni and Daniel Angulo

        Stephen Nusko added 2 comments

        File remoting/protocol/pseudo_tcp.h
        Line 124, Patchset 17 (Latest): // RAW_PTR_EXCLUSION: Stack-scoped
        RAW_PTR_EXCLUSION base::span<const uint8_t> data;
        Stephen Nusko

        I think I just requested it as part of requesting the switch from raw_span -> span, please feel free to check if the plugin complains and you can remove it if it doesn't.

        File remoting/protocol/pseudo_tcp.cc
        Line 102, Patchset 14: // Added methods for base::span support
        uint8_t* begin() { return data_.data(); }
        const uint8_t* begin() const { return data_.data(); }
        uint8_t* end() { return UNSAFE_TODO(data_.data() + data_.size()); }
        const uint8_t* end() const {
        return UNSAFE_TODO(data_.data() + data_.size());
        }
        Stephen Nusko . unresolved

        What is this for? I see the comment but I don't understand it?

        1) Why would we need iterator type methods to support base::span?
        2) data_ is a vector we can just return their iterators if needed .begin()/end()?

        Daniel Angulo

        Compiler was complaining that this class can't be implicitly converted to a span, I had to add those methods to make it compatible with spans.

        Stephen Nusko

        Yes it isn't, but this isn't the best way to make it so. Spans just need a .data() and .size() method and that is safer (no UNSAFE_TODO for example).

        Can you either

        1) rename `Data()` to `data() and `Length()` to `size()`
        2) just add a `data()` and `size()` to make it convertable to span.

        Daniel Angulo

        adding data() and size() seems insufficient, I get this error: no viable constructor or deduction guide for deduction of template arguments of 'base::span'. candidate template ignored: couldn't infer template argument 'ElementType'. note: candidate template ignored: couldn't infer template argument 'ElementType'. candidate template ignored: constraints not satisfied [with R = ByteBufferWriter &] because 'ByteBufferWriter &' does not satisfy 'contiguous_range'

        Stephen Nusko

        deduction guides just mean that you have to potentially be a bit more explicit about what the type is, this is because the ByteBuffer is a span of uint8_ts but doesn't tell span anything about what type it stores. However if you said `base::span<uint8_t>(buf)` it would be just fine.

        In this case it is complaining about `contiguous_range` which you can read about [here](https://en.cppreference.com/w/cpp/ranges/contiguous_range.html)

        but in essence it sounds like we need a `.begin()` to check the `data() == begin()`, can you

        either
        1) Just update the complaining callsite with the proper type.
        2) Add only the .begin() iterator
        3) Add full proper iterator support. I.E. add the following to the top of the class:
        ```
        using iterator = std::vector<uint8_t>::iterator;
        using const_iterator = std::vector<uint8_t>::const_iterator;
        ```
        And then modify the iterator functions to be:
        ```
        iterator begin() { return data_.begin(); }
        const_iterator begin() const { return data_.begin(); }
        iterator end() { return data_.end(); }
        const_iterator end() const { return data_.end(); }
        ```

        Then everything should work well and be properly hardened (checked iterator) without UNSAFE_TODO.

        I prefer 1 or 3 over two since the iterator that returns just a pointer is unsafe if ever used to index.

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Arthur Sonzogni
        • Daniel Angulo
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Owners
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: Id1a0ff3462edd3d7fa119beff620570f1893a0d8
        Gerrit-Change-Number: 7526157
        Gerrit-PatchSet: 17
        Gerrit-Owner: Daniel Angulo <angd...@google.com>
        Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
        Gerrit-Reviewer: Daniel Angulo <angd...@google.com>
        Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
        Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
        Gerrit-Attention: Daniel Angulo <angd...@google.com>
        Gerrit-Attention: Arthur Sonzogni <arthurs...@chromium.org>
        Gerrit-Comment-Date: Mon, 09 Mar 2026 07:49:03 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: Stephen Nusko <nus...@chromium.org>
        Comment-In-Reply-To: Daniel Angulo <angd...@google.com>
        Comment-In-Reply-To: Arthur Sonzogni <arthurs...@chromium.org>
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Daniel Angulo (Gerrit)

        unread,
        Mar 9, 2026, 1:21:23 PM (5 days ago) Mar 9
        to Arthur Sonzogni, Code Review Nudger, Stephen Nusko, AyeAye, Chromium LUCI CQ, chromotin...@chromium.org
        Attention needed from Arthur Sonzogni and Stephen Nusko

        Daniel Angulo added 3 comments

        Commit Message
        Line 1, Patchset 17:Parent: 56633fc2 (Replace WIDGET_OWNS_NATIVE_WIDGET with CLIENT_OWNS_WIDGET in chrome/browser/preloading/preview)
        Arthur Sonzogni . resolved

        Hey Daniel!

        Could you please try to compile your patches locally before requesting a code review? This would shorten the time to submit a patch, because you will be able to fix the issue before waiting on the code review.

        You can also wait on the `git cl try` run to finish.

        ---

        I fetched the patch locally and got:
        ```
        ../../remoting/protocol/pseudo_tcp.cc:121:56: error: no viable conversion from 'std::optional<span<element_type, 4UL>>' (aka 'std::optional<span<const unsigned char, 4UL>>') to 'std::span<const uint8_t, 4U>' (aka 'std::span<const unsigned char, 4U>')
        121 | *val = base::NetToHost32(base::U32FromNativeEndian(bytes));
        | ^~~~~

        ```

        Daniel Angulo

        didn't know about git cl try, thank you!
        now it compiles

        File remoting/protocol/pseudo_tcp.h
        Line 124, Patchset 17: // RAW_PTR_EXCLUSION: Stack-scoped

        RAW_PTR_EXCLUSION base::span<const uint8_t> data;
        Arthur Sonzogni . unresolved

        Is it necessary?

        I know the clang plugin does exclude `STACK_ALLOCATED()`:
        https://source.chromium.org/chromium/chromium/src/+/main:tools/clang/raw_ptr_plugin/RawPtrHelpers.h;l=495-504?q=should_exclude_stack_allocated_records%20-f:third_party

        Stephen Nusko

        I think I just requested it as part of requesting the switch from raw_span -> span, please feel free to check if the plugin complains and you can remove it if it doesn't.

        Daniel Angulo

        how can I check the plugin? it compiles successfully and passes the tests btw.

        File remoting/protocol/pseudo_tcp.cc
        Line 102, Patchset 14: // Added methods for base::span support
        uint8_t* begin() { return data_.data(); }
        const uint8_t* begin() const { return data_.data(); }
        uint8_t* end() { return UNSAFE_TODO(data_.data() + data_.size()); }
        const uint8_t* end() const {
        return UNSAFE_TODO(data_.data() + data_.size());
        }
        Stephen Nusko . resolved
        Daniel Angulo

        tried 1, still complaining about contiguous range, tried 2, then is not necessary 1. No need for UNSAFE_TODO here.

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Arthur Sonzogni
        • Stephen Nusko
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Owners
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: Id1a0ff3462edd3d7fa119beff620570f1893a0d8
        Gerrit-Change-Number: 7526157
        Gerrit-PatchSet: 18
        Gerrit-Owner: Daniel Angulo <angd...@google.com>
        Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
        Gerrit-Reviewer: Daniel Angulo <angd...@google.com>
        Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
        Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
        Gerrit-Attention: Stephen Nusko <nus...@chromium.org>
        Gerrit-Attention: Arthur Sonzogni <arthurs...@chromium.org>
        Gerrit-Comment-Date: Mon, 09 Mar 2026 17:21:14 +0000
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Arthur Sonzogni (Gerrit)

        unread,
        Mar 9, 2026, 1:30:16 PM (5 days ago) Mar 9
        to Daniel Angulo, Arthur Sonzogni, Code Review Nudger, Stephen Nusko, AyeAye, Chromium LUCI CQ, chromotin...@chromium.org
        Attention needed from Arthur Sonzogni, Daniel Angulo and Stephen Nusko

        Arthur Sonzogni added 1 comment

        File remoting/protocol/pseudo_tcp.h
        Line 124, Patchset 17: // RAW_PTR_EXCLUSION: Stack-scoped
        RAW_PTR_EXCLUSION base::span<const uint8_t> data;
        Arthur Sonzogni . unresolved

        Is it necessary?

        I know the clang plugin does exclude `STACK_ALLOCATED()`:
        https://source.chromium.org/chromium/chromium/src/+/main:tools/clang/raw_ptr_plugin/RawPtrHelpers.h;l=495-504?q=should_exclude_stack_allocated_records%20-f:third_party

        Stephen Nusko

        I think I just requested it as part of requesting the switch from raw_span -> span, please feel free to check if the plugin complains and you can remove it if it doesn't.

        Daniel Angulo

        how can I check the plugin? it compiles successfully and passes the tests btw.

        Arthur Sonzogni

        The plugin is enabled by default.

        Remove `RAW_PTR_EXCLUSION` (+ comment)

        • If it compiles => then commit the removal
        • If it doesn't => keep it.
        Open in Gerrit

        Related details

        Attention is currently required from:
        • Arthur Sonzogni
        • Daniel Angulo
        • Stephen Nusko
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Owners
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: Id1a0ff3462edd3d7fa119beff620570f1893a0d8
        Gerrit-Change-Number: 7526157
        Gerrit-PatchSet: 18
        Gerrit-Owner: Daniel Angulo <angd...@google.com>
        Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
        Gerrit-Reviewer: Daniel Angulo <angd...@google.com>
        Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
        Gerrit-CC: Arthur Sonzogni <arthurs...@google.com>
        Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
        Gerrit-Attention: Stephen Nusko <nus...@chromium.org>
        Gerrit-Attention: Daniel Angulo <angd...@google.com>
        Gerrit-Attention: Arthur Sonzogni <arthurs...@chromium.org>
        Gerrit-Comment-Date: Mon, 09 Mar 2026 17:30:05 +0000
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Arthur Sonzogni (Gerrit)

        unread,
        Mar 10, 2026, 8:47:09 AM (4 days ago) Mar 10
        to Daniel Angulo, Arthur Sonzogni, Code Review Nudger, Stephen Nusko, AyeAye, Chromium LUCI CQ, chromotin...@chromium.org
        Attention needed from Daniel Angulo

        Arthur Sonzogni added 1 comment

        File remoting/protocol/pseudo_tcp.h
        Line 124, Patchset 17: // RAW_PTR_EXCLUSION: Stack-scoped
        RAW_PTR_EXCLUSION base::span<const uint8_t> data;
        Arthur Sonzogni . unresolved

        Is it necessary?

        I know the clang plugin does exclude `STACK_ALLOCATED()`:
        https://source.chromium.org/chromium/chromium/src/+/main:tools/clang/raw_ptr_plugin/RawPtrHelpers.h;l=495-504?q=should_exclude_stack_allocated_records%20-f:third_party

        Stephen Nusko

        I think I just requested it as part of requesting the switch from raw_span -> span, please feel free to check if the plugin complains and you can remove it if it doesn't.

        Daniel Angulo

        how can I check the plugin? it compiles successfully and passes the tests btw.

        Arthur Sonzogni

        The plugin is enabled by default.

        Remove `RAW_PTR_EXCLUSION` (+ comment)

        • If it compiles => then commit the removal
        • If it doesn't => keep it.
        Arthur Sonzogni

        *(replying with my @google account to wait on this)*

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Daniel Angulo
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Owners
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: Id1a0ff3462edd3d7fa119beff620570f1893a0d8
        Gerrit-Change-Number: 7526157
        Gerrit-PatchSet: 18
        Gerrit-Owner: Daniel Angulo <angd...@google.com>
        Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
        Gerrit-Reviewer: Daniel Angulo <angd...@google.com>
        Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
        Gerrit-CC: Arthur Sonzogni <arthurs...@google.com>
        Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
        Gerrit-Attention: Daniel Angulo <angd...@google.com>
        Gerrit-Comment-Date: Tue, 10 Mar 2026 12:46:57 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: Stephen Nusko <nus...@chromium.org>
        Comment-In-Reply-To: Daniel Angulo <angd...@google.com>
        Comment-In-Reply-To: Arthur Sonzogni <arthurs...@chromium.org>
        Comment-In-Reply-To: Arthur Sonzogni <arthurs...@google.com>
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Daniel Angulo (Gerrit)

        unread,
        Mar 10, 2026, 12:15:57 PM (4 days ago) Mar 10
        to Arthur Sonzogni, Arthur Sonzogni, Code Review Nudger, Stephen Nusko, AyeAye, Chromium LUCI CQ, chromotin...@chromium.org
        Attention needed from Arthur Sonzogni, Arthur Sonzogni and Stephen Nusko

        Daniel Angulo added 1 comment

        File remoting/protocol/pseudo_tcp.h
        Line 124, Patchset 17: // RAW_PTR_EXCLUSION: Stack-scoped
        RAW_PTR_EXCLUSION base::span<const uint8_t> data;
        Arthur Sonzogni . resolved

        Is it necessary?

        I know the clang plugin does exclude `STACK_ALLOCATED()`:
        https://source.chromium.org/chromium/chromium/src/+/main:tools/clang/raw_ptr_plugin/RawPtrHelpers.h;l=495-504?q=should_exclude_stack_allocated_records%20-f:third_party

        Stephen Nusko

        I think I just requested it as part of requesting the switch from raw_span -> span, please feel free to check if the plugin complains and you can remove it if it doesn't.

        Daniel Angulo

        how can I check the plugin? it compiles successfully and passes the tests btw.

        Arthur Sonzogni

        The plugin is enabled by default.

        Remove `RAW_PTR_EXCLUSION` (+ comment)

        • If it compiles => then commit the removal
        • If it doesn't => keep it.
        Arthur Sonzogni

        *(replying with my @google account to wait on this)*

        Daniel Angulo

        it does compiles with the removal, so i'm commiting the removal. thanks!

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Arthur Sonzogni
        • Arthur Sonzogni
        • Stephen Nusko
        Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement is not satisfiedCode-Owners
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: Id1a0ff3462edd3d7fa119beff620570f1893a0d8
          Gerrit-Change-Number: 7526157
          Gerrit-PatchSet: 19
          Gerrit-Owner: Daniel Angulo <angd...@google.com>
          Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
          Gerrit-Reviewer: Daniel Angulo <angd...@google.com>
          Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
          Gerrit-CC: Arthur Sonzogni <arthurs...@google.com>
          Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
          Gerrit-Attention: Stephen Nusko <nus...@chromium.org>
          Gerrit-Attention: Arthur Sonzogni <arthurs...@chromium.org>
          Gerrit-Attention: Arthur Sonzogni <arthurs...@google.com>
          Gerrit-Comment-Date: Tue, 10 Mar 2026 16:15:50 +0000
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Arthur Sonzogni (Gerrit)

          unread,
          Mar 10, 2026, 1:09:07 PM (4 days ago) Mar 10
          to Daniel Angulo, Arthur Sonzogni, Code Review Nudger, Stephen Nusko, AyeAye, Chromium LUCI CQ, chromotin...@chromium.org
          Attention needed from Arthur Sonzogni, Daniel Angulo and Stephen Nusko

          Arthur Sonzogni added 7 comments

          Arthur Sonzogni . resolved

          Thanks!

          File remoting/protocol/pseudo_tcp.cc
          Line 94, Patchset 19 (Latest): auto bytes = base::byte_span_from_ref(nval);
          data_.insert(data_.end(), bytes.begin(), bytes.end());
          }
          Arthur Sonzogni . unresolved

          Would that work:
          ```
          data_.append_range(bytes);
          ```
          ?

          Line 98, Patchset 19 (Latest): uint16_t nval = base::HostToNet16(val);
          auto bytes = base::byte_span_from_ref(nval);
          data_.insert(data_.end(), bytes.begin(), bytes.end());
          }
          Arthur Sonzogni . unresolved

          ditto? `std::vector::append_range`

          Line 593, Patchset 19 (Latest): auto buffer_storage = base::HeapArray<uint8_t>::WithSize(MAX_PACKET);
          base::span<uint8_t> buffer(buffer_storage);

          base::SpanWriter writer(buffer);
          Arthur Sonzogni . unresolved
          I suspect HeapArray is convertible to base::span implicitly:
          ```
          auto buffer = base::HeapArray<uint8_t>::WithSize(MAX_PACKET);
          base::SpanWriter writer(buffer);
          ```
          It it doesn't, you can do it explictely:
          ```
          ```
          auto buffer = base::HeapArray<uint8_t>::WithSize(MAX_PACKET);
          base::SpanWriter writer(buffer.as_span());
          ```
          Line 1265, Patchset 19 (Latest): queue(base::span(buf), true);
          Arthur Sonzogni . unresolved

          I suspect you don't need to explicitly use `base::span`, because it has an implicit constructor:
          ```
          queue(buf, true)
          ```

          Does that work?

          Line 1404, Patchset 19 (Latest): new_buffer_first.copy_from_nonoverlapping(old_buffer_start);
          Arthur Sonzogni . unresolved

          Let's always `copy_from`. This is always safe, and we don't have evidence the `copy_from_nonoverlapping` to be slower.

          File remoting/protocol/pseudo_tcp_unittest.cc
          Line 526, Patchset 19 (Latest): received = receiver_->Recv(base::span(block));
          Arthur Sonzogni . unresolved

          ditto: (remove base::span)

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Arthur Sonzogni
          • Daniel Angulo
          • Stephen Nusko
          Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement is not satisfiedCode-Owners
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            • requirement is not satisfiedReview-Enforcement
            Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
            Gerrit-MessageType: comment
            Gerrit-Project: chromium/src
            Gerrit-Branch: main
            Gerrit-Change-Id: Id1a0ff3462edd3d7fa119beff620570f1893a0d8
            Gerrit-Change-Number: 7526157
            Gerrit-PatchSet: 19
            Gerrit-Owner: Daniel Angulo <angd...@google.com>
            Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
            Gerrit-Reviewer: Daniel Angulo <angd...@google.com>
            Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
            Gerrit-CC: Arthur Sonzogni <arthurs...@google.com>
            Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
            Gerrit-Attention: Stephen Nusko <nus...@chromium.org>
            Gerrit-Attention: Daniel Angulo <angd...@google.com>
            Gerrit-Attention: Arthur Sonzogni <arthurs...@google.com>
            Gerrit-Comment-Date: Tue, 10 Mar 2026 17:08:51 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: No
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Stephen Nusko (Gerrit)

            unread,
            Mar 10, 2026, 10:17:18 PM (4 days ago) Mar 10
            to Daniel Angulo, Arthur Sonzogni, Arthur Sonzogni, Code Review Nudger, AyeAye, Chromium LUCI CQ, chromotin...@chromium.org
            Attention needed from Arthur Sonzogni and Daniel Angulo

            Stephen Nusko added 4 comments

            File remoting/protocol/pseudo_tcp.h
            Line 16, Patchset 19 (Latest):#include "base/memory/raw_span.h"
            Stephen Nusko . unresolved

            This is now unused right?

            (actually appears to be in the .cc so should be moved there in the current patchset, but I added a comment to remove that usage as well so probably delete it along with doing that comment).

            File remoting/protocol/pseudo_tcp.cc
            Line 155, Patchset 19 (Latest): base::raw_span<const uint8_t> data_;
            Stephen Nusko . unresolved

            Question can you make this class be STACK_ALLOCATED as well? Appears to be used as such and this can be a regular span.


            Or...

            Just remove this class entirely? It is just a SpanReader no? Doesn't need its own class?

            File remoting/protocol/pseudotcp_adapter.cc
            Line 185, Patchset 19 (Latest):
            Stephen Nusko . unresolved

            Add a similar `CHECK_EQ(buffer->span().size(), buffer_size);`?

            Line 189, Patchset 19 (Latest): int result = pseudo_tcp_.Send(buffer->first(buffer_size));
            Stephen Nusko . unresolved

            nit: isn't this `buffer->span()`? here and below? or is there a difference here for some reason?

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Arthur Sonzogni
            • Daniel Angulo
            Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement is not satisfiedCode-Owners
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            • requirement is not satisfiedReview-Enforcement
            Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
            Gerrit-MessageType: comment
            Gerrit-Project: chromium/src
            Gerrit-Branch: main
            Gerrit-Change-Id: Id1a0ff3462edd3d7fa119beff620570f1893a0d8
            Gerrit-Change-Number: 7526157
            Gerrit-PatchSet: 19
            Gerrit-Owner: Daniel Angulo <angd...@google.com>
            Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
            Gerrit-Reviewer: Daniel Angulo <angd...@google.com>
            Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
            Gerrit-CC: Arthur Sonzogni <arthurs...@google.com>
            Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
            Gerrit-Attention: Daniel Angulo <angd...@google.com>
            Gerrit-Attention: Arthur Sonzogni <arthurs...@google.com>
            Gerrit-Comment-Date: Wed, 11 Mar 2026 02:16:56 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: No
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Stephen Nusko (Gerrit)

            unread,
            Mar 10, 2026, 10:48:48 PM (4 days ago) Mar 10
            to Daniel Angulo, Arthur Sonzogni, Arthur Sonzogni, Code Review Nudger, AyeAye, Chromium LUCI CQ, chromotin...@chromium.org
            Attention needed from Arthur Sonzogni and Daniel Angulo

            Stephen Nusko added 1 comment

            File remoting/protocol/pseudo_tcp.cc
            Line 122, Patchset 19 (Latest): *val = base::NetToHost32(base::U32FromNativeEndian(bytes.value()));
            Stephen Nusko . unresolved

            Is this correct? Is there good tests for this? wondering because in the writer it does `HostToNet16` (so the wire format is always big endian), so perhaps this should be:

            `base::NetToHost32(base::U32FromBigEndian(bytes.value()));`?

            Can you verify the old behaviour and ensure we're properly replicating the behaviour? Perhaps check that there is a test covering this case?

            Gerrit-Comment-Date: Wed, 11 Mar 2026 02:48:18 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: No
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Daniel Angulo (Gerrit)

            unread,
            Mar 11, 2026, 6:10:30 PM (3 days ago) Mar 11
            to Arthur Sonzogni, Arthur Sonzogni, Code Review Nudger, Stephen Nusko, AyeAye, Chromium LUCI CQ, chromotin...@chromium.org
            Attention needed from Arthur Sonzogni, Arthur Sonzogni and Stephen Nusko

            Daniel Angulo added 9 comments

            File remoting/protocol/pseudo_tcp.h
            Line 16, Patchset 19:#include "base/memory/raw_span.h"
            Stephen Nusko . resolved

            This is now unused right?

            (actually appears to be in the .cc so should be moved there in the current patchset, but I added a comment to remove that usage as well so probably delete it along with doing that comment).

            Daniel Angulo

            Done

            File remoting/protocol/pseudo_tcp.cc
            Line 94, Patchset 19: auto bytes = base::byte_span_from_ref(nval);
            data_.insert(data_.end(), bytes.begin(), bytes.end());
            }
            Arthur Sonzogni . resolved

            Would that work:
            ```
            data_.append_range(bytes);
            ```
            ?

            Daniel Angulo

            Done

            Line 98, Patchset 19: uint16_t nval = base::HostToNet16(val);

            auto bytes = base::byte_span_from_ref(nval);
            data_.insert(data_.end(), bytes.begin(), bytes.end());
            }
            Arthur Sonzogni . resolved

            ditto? `std::vector::append_range`

            Daniel Angulo

            Done

            Line 593, Patchset 19: auto buffer_storage = base::HeapArray<uint8_t>::WithSize(MAX_PACKET);

            base::span<uint8_t> buffer(buffer_storage);

            base::SpanWriter writer(buffer);
            Arthur Sonzogni . resolved
            I suspect HeapArray is convertible to base::span implicitly:
            ```
            auto buffer = base::HeapArray<uint8_t>::WithSize(MAX_PACKET);
            base::SpanWriter writer(buffer);
            ```
            It it doesn't, you can do it explictely:
            ```
            ```
            auto buffer = base::HeapArray<uint8_t>::WithSize(MAX_PACKET);
            base::SpanWriter writer(buffer.as_span());
            ```
            Daniel Angulo

            Done

            Line 1265, Patchset 19: queue(base::span(buf), true);
            Arthur Sonzogni . resolved

            I suspect you don't need to explicitly use `base::span`, because it has an implicit constructor:
            ```
            queue(buf, true)
            ```

            Does that work?

            Daniel Angulo

            Done

            Line 1404, Patchset 19: new_buffer_first.copy_from_nonoverlapping(old_buffer_start);
            Arthur Sonzogni . resolved

            Let's always `copy_from`. This is always safe, and we don't have evidence the `copy_from_nonoverlapping` to be slower.

            Daniel Angulo

            Done

            File remoting/protocol/pseudo_tcp_unittest.cc
            Line 526, Patchset 19: received = receiver_->Recv(base::span(block));
            Arthur Sonzogni . resolved

            ditto: (remove base::span)

            Daniel Angulo

            Done

            File remoting/protocol/pseudotcp_adapter.cc
            Stephen Nusko . unresolved

            Add a similar `CHECK_EQ(buffer->span().size(), buffer_size);`?

            Daniel Angulo

            check fails with: buffer->span().size() == buffer_size (102400 vs. 1024). and because of that it needs "first" in line 189

            Line 189, Patchset 19: int result = pseudo_tcp_.Send(buffer->first(buffer_size));
            Stephen Nusko . unresolved

            nit: isn't this `buffer->span()`? here and below? or is there a difference here for some reason?

            Daniel Angulo

            check in line 185, fails with: buffer->span().size() == buffer_size (102400 vs. 1024). and because of that it needs "first" in line 189. there was a similar thread about this in PseudoTcpAdapter::Core::Read line 154

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Arthur Sonzogni
            • Arthur Sonzogni
            • Stephen Nusko
            Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement is not satisfiedCode-Owners
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            • requirement is not satisfiedReview-Enforcement
            Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
            Gerrit-MessageType: comment
            Gerrit-Project: chromium/src
            Gerrit-Branch: main
            Gerrit-Change-Id: Id1a0ff3462edd3d7fa119beff620570f1893a0d8
            Gerrit-Change-Number: 7526157
            Gerrit-PatchSet: 20
            Gerrit-Owner: Daniel Angulo <angd...@google.com>
            Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
            Gerrit-Reviewer: Daniel Angulo <angd...@google.com>
            Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
            Gerrit-CC: Arthur Sonzogni <arthurs...@google.com>
            Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
            Gerrit-Attention: Stephen Nusko <nus...@chromium.org>
            Gerrit-Attention: Arthur Sonzogni <arthurs...@chromium.org>
            Gerrit-Attention: Arthur Sonzogni <arthurs...@google.com>
            Gerrit-Comment-Date: Wed, 11 Mar 2026 22:10:23 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: No
            Comment-In-Reply-To: Stephen Nusko <nus...@chromium.org>
            Comment-In-Reply-To: Arthur Sonzogni <arthurs...@chromium.org>
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Arthur Sonzogni (Gerrit)

            unread,
            Mar 13, 2026, 6:49:51 AM (yesterday) Mar 13
            to Daniel Angulo, Arthur Sonzogni, Code Review Nudger, Stephen Nusko, AyeAye, Chromium LUCI CQ, chromotin...@chromium.org
            Attention needed from Arthur Sonzogni and Daniel Angulo

            Arthur Sonzogni added 1 comment

            File remoting/protocol/pseudo_tcp.cc
            Line 116, Patchset 20 (Latest):class ByteBufferReader {
            public:
            explicit ByteBufferReader(base::span<const uint8_t> data) : data_(data) {}
            bool ReadUInt32(uint32_t* val) {

            auto bytes = base::as_bytes(data_.subspan(pos_, sizeof(uint32_t)))
            .to_fixed_extent<sizeof(uint32_t)>();
            *val = base::NetToHost32(base::U32FromBigEndian(bytes.value()));
            pos_ += sizeof(uint32_t);
            return true;
            }
            bool ReadUInt16(uint16_t* val) {
            if (pos_ + sizeof(uint16_t) > data_.size()) {
            return false;
            }
            *val = base::NetToHost16(
            *reinterpret_cast<const uint16_t*>(data_.subspan(pos_).data()));
            pos_ += sizeof(uint16_t);
            return true;
            }
            bool ReadUInt8(uint8_t* val) {
            if (pos_ + sizeof(uint8_t) > data_.size()) {
            return false;
            }
            *val = data_[pos_++];
            return true;
            }
            bool ReadString(base::span<char> str) {
            if (pos_ + str.size() > data_.size()) {
            return false;
            }
            base::as_writable_bytes(str).copy_from(data_.subspan(pos_, str.size()));
            pos_ += str.size();
            return true;
            }
            size_t Length() const { return data_.size() - pos_; }
            const uint8_t* Data() const { return &data_[pos_]; }
            void Consume(size_t len) { pos_ += len; }

            STACK_ALLOCATED();
            base::span<const uint8_t> data_;
            size_t pos_ = 0;
            };
            Arthur Sonzogni . unresolved

            `STACK_ALLOCATED()` should be added at the top of the class.

            Alos, I wonder if we couldn't remove ByteBufferReader in favor of base::SpanReader?

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Arthur Sonzogni
            • Daniel Angulo
            Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement is not satisfiedCode-Owners
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            • requirement is not satisfiedReview-Enforcement
            Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
            Gerrit-MessageType: comment
            Gerrit-Project: chromium/src
            Gerrit-Branch: main
            Gerrit-Change-Id: Id1a0ff3462edd3d7fa119beff620570f1893a0d8
            Gerrit-Change-Number: 7526157
            Gerrit-PatchSet: 20
            Gerrit-Owner: Daniel Angulo <angd...@google.com>
            Gerrit-Reviewer: Arthur Sonzogni <arthurs...@chromium.org>
            Gerrit-Reviewer: Daniel Angulo <angd...@google.com>
            Gerrit-Reviewer: Stephen Nusko <nus...@chromium.org>
            Gerrit-CC: Arthur Sonzogni <arthurs...@google.com>
            Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
            Gerrit-Attention: Daniel Angulo <angd...@google.com>
            Gerrit-Attention: Arthur Sonzogni <arthurs...@google.com>
            Gerrit-Comment-Date: Fri, 13 Mar 2026 10:49:39 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: No
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy
            Reply all
            Reply to author
            Forward
            0 new messages