[base] Introduce base::apple::NSDataWithBytes() [chromium/src : main]

0 views
Skip to first unread message

Mark Mentovai (Gerrit)

unread,
Feb 10, 2026, 2:10:53 PM (11 days ago) Feb 10
to Mikel Astiz, Avi Drissman, (Julie)Jeongeun Kim, AyeAye, Lei Zhang, Chromium LUCI CQ, chromium...@chromium.org, christia...@chromium.org, abigailbk...@google.com, extension...@chromium.org, ios-revie...@chromium.org, francisjp...@google.com, ios-web-view...@google.com, kyungjunle...@google.com, niharm...@google.com, omnibox-...@chromium.org, dtraino...@chromium.org, net-r...@chromium.org, jdonnel...@chromium.org, mattreyno...@chromium.org, chromium-a...@chromium.org, yuzo+...@chromium.org, marq+...@chromium.org, browser-comp...@chromium.org, filesapp...@chromium.org, ananyasee...@google.com, rkgibso...@chromium.org, nektar...@chromium.org, dtseng...@chromium.org, josiah...@chromium.org, feature-me...@chromium.org, aixba+wat...@chromium.org, dcheng+c...@chromium.org, derinel+wat...@google.com, dibyapal+wa...@chromium.org, dmurph+watc...@chromium.org, ios-rev...@chromium.org, ios-r...@chromium.org, japhet+...@chromium.org, kuragin+web-ap...@chromium.org, loyso...@chromium.org, mac-r...@chromium.org, mek+w...@chromium.org, mgiuca...@chromium.org, philli...@chromium.org, rsesek...@chromium.org, webap...@microsoft.com, webauthn...@chromium.org, zelin+watch-we...@chromium.org
Attention needed from Mikel Astiz

Mark Mentovai added 2 comments

Patchset-level comments
File-level comment, Patchset 3 (Latest):
Mark Mentovai . resolved

+avi as someone else who would be interested in this and who might have an opinion.

File base/apple/foundation_util.h
Line 329, Patchset 1:inline NSData* NSDataWithBytes(base::span<const uint8_t> data) {
Lei Zhang . unresolved

Most of the surrounding functions are all named "FooToBar". Should this follow that pattern?

Mark Mentovai

Most of the surrounding functions are all named "FooToBar". Should this follow that pattern?

I think this didn’t exist before because it’s very easy to write. In addition, unlike the functions above, there’s nothing compile-time UNSAFE about this operation that demands a wrapper.

A little codesearching shows that we often do this for strings, too.

Given that the functions above AND BELOW call this a “Span”, we should probably keep the naming consistent.

If you’re adding this, you’d probably also want a mutable variant (see above and below as well).

Open in Gerrit

Related details

Attention is currently required from:
  • Mikel Astiz
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: Ia8ce388928716670b7daf1c0bc49fba9f23caf91
Gerrit-Change-Number: 7560135
Gerrit-PatchSet: 3
Gerrit-Owner: Mikel Astiz <mas...@chromium.org>
Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
Gerrit-Reviewer: Mikel Astiz <mas...@chromium.org>
Gerrit-CC: (Julie)Jeongeun Kim <je_jul...@chromium.org>
Gerrit-CC: Akihiro Ota <akihi...@chromium.org>
Gerrit-CC: Avi Drissman <a...@chromium.org>
Gerrit-CC: Mark Mentovai <ma...@chromium.org>
Gerrit-Attention: Mikel Astiz <mas...@chromium.org>
Gerrit-Comment-Date: Tue, 10 Feb 2026 19:10:47 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Lei Zhang <the...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Mikel Astiz (Gerrit)

unread,
Feb 10, 2026, 2:21:04 PM (11 days ago) Feb 10
to Avi Drissman, (Julie)Jeongeun Kim, AyeAye, Mark Mentovai, Lei Zhang, Chromium LUCI CQ, chromium...@chromium.org, christia...@chromium.org, abigailbk...@google.com, extension...@chromium.org, ios-revie...@chromium.org, francisjp...@google.com, ios-web-view...@google.com, kyungjunle...@google.com, niharm...@google.com, omnibox-...@chromium.org, dtraino...@chromium.org, net-r...@chromium.org, jdonnel...@chromium.org, mattreyno...@chromium.org, chromium-a...@chromium.org, yuzo+...@chromium.org, marq+...@chromium.org, browser-comp...@chromium.org, filesapp...@chromium.org, ananyasee...@google.com, rkgibso...@chromium.org, nektar...@chromium.org, dtseng...@chromium.org, josiah...@chromium.org, feature-me...@chromium.org, aixba+wat...@chromium.org, dcheng+c...@chromium.org, derinel+wat...@google.com, dibyapal+wa...@chromium.org, dmurph+watc...@chromium.org, ios-rev...@chromium.org, ios-r...@chromium.org, japhet+...@chromium.org, kuragin+web-ap...@chromium.org, loyso...@chromium.org, mac-r...@chromium.org, mek+w...@chromium.org, mgiuca...@chromium.org, philli...@chromium.org, rsesek...@chromium.org, webap...@microsoft.com, webauthn...@chromium.org, zelin+watch-we...@chromium.org
Attention needed from Lei Zhang and Mark Mentovai

Mikel Astiz added 1 comment

File base/apple/foundation_util.h
Line 329, Patchset 1:inline NSData* NSDataWithBytes(base::span<const uint8_t> data) {
Lei Zhang . unresolved

Most of the surrounding functions are all named "FooToBar". Should this follow that pattern?

Mark Mentovai

Most of the surrounding functions are all named "FooToBar". Should this follow that pattern?

I think this didn’t exist before because it’s very easy to write. In addition, unlike the functions above, there’s nothing compile-time UNSAFE about this operation that demands a wrapper.

A little codesearching shows that we often do this for strings, too.

Given that the functions above AND BELOW call this a “Span”, we should probably keep the naming consistent.

If you’re adding this, you’d probably also want a mutable variant (see above and below as well).

Mikel Astiz

Most of the surrounding functions are all named "FooToBar". Should this follow that pattern?

I think this didn’t exist before because it’s very easy to write. In addition, unlike the functions above, there’s nothing compile-time UNSAFE about this operation that demands a wrapper.

Let me know if there's no appetite for this function and I don't mind abandoning this patch.


A little codesearching shows that we often do this for strings, too.

Even if this patch, there are a number of occurrences that start with strings, which then need to use `base::as_byte_span`. I can look into another function for extra convenience, either in this patch or in a follow-up (please advise).


Given that the functions above AND BELOW call this a “Span”, we should probably keep the naming consistent.

The reason I didn't add this in the name is:
1. Most containers convert implicitly to `span`, so from the caller's standpoint `span` isn't particularly relevant (as opposed to the API signatures where `span` is returned).

2. I thought it would be nice to keep the name similar to `dataWithBytes`, so it reads familiar.

That said, I am not feeling strongly and open to any name you suggest.


If you’re adding this, you’d probably also want a mutable variant (see above and below as well).

I don't mind doing that in a follow-up (as this semi-automated CL is already large).

Open in Gerrit

Related details

Attention is currently required from:
  • Lei Zhang
  • Mark Mentovai
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: Ia8ce388928716670b7daf1c0bc49fba9f23caf91
Gerrit-Change-Number: 7560135
Gerrit-PatchSet: 3
Gerrit-Owner: Mikel Astiz <mas...@chromium.org>
Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
Gerrit-Reviewer: Mikel Astiz <mas...@chromium.org>
Gerrit-CC: (Julie)Jeongeun Kim <je_jul...@chromium.org>
Gerrit-CC: Akihiro Ota <akihi...@chromium.org>
Gerrit-CC: Avi Drissman <a...@chromium.org>
Gerrit-CC: Mark Mentovai <ma...@chromium.org>
Gerrit-Attention: Lei Zhang <the...@chromium.org>
Gerrit-Attention: Mark Mentovai <ma...@chromium.org>
Gerrit-Comment-Date: Tue, 10 Feb 2026 19:20:51 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Lei Zhang <the...@chromium.org>
Comment-In-Reply-To: Mark Mentovai <ma...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Mikel Astiz (Gerrit)

unread,
Feb 12, 2026, 11:27:57 AM (9 days ago) Feb 12
to Avi Drissman, (Julie)Jeongeun Kim, AyeAye, Mark Mentovai, Lei Zhang, Chromium LUCI CQ, chromium...@chromium.org, christia...@chromium.org, abigailbk...@google.com, extension...@chromium.org, ios-revie...@chromium.org, francisjp...@google.com, ios-web-view...@google.com, kyungjunle...@google.com, niharm...@google.com, omnibox-...@chromium.org, dtraino...@chromium.org, net-r...@chromium.org, jdonnel...@chromium.org, mattreyno...@chromium.org, chromium-a...@chromium.org, yuzo+...@chromium.org, marq+...@chromium.org, browser-comp...@chromium.org, filesapp...@chromium.org, ananyasee...@google.com, rkgibso...@chromium.org, nektar...@chromium.org, dtseng...@chromium.org, josiah...@chromium.org, feature-me...@chromium.org, aixba+wat...@chromium.org, dcheng+c...@chromium.org, derinel+wat...@google.com, dibyapal+wa...@chromium.org, dmurph+watc...@chromium.org, ios-rev...@chromium.org, ios-r...@chromium.org, japhet+...@chromium.org, kuragin+web-ap...@chromium.org, loyso...@chromium.org, mac-r...@chromium.org, mek+w...@chromium.org, mgiuca...@chromium.org, philli...@chromium.org, rsesek...@chromium.org, webap...@microsoft.com, webauthn...@chromium.org, zelin+watch-we...@chromium.org
File base/apple/foundation_util.h

I prepared another patch (parent patch) targeting an API for strings specifically.


>
> Given that the functions above AND BELOW call this a “Span”, we should probably keep the naming consistent.

The reason I didn't add this in the name is:
1. Most containers convert implicitly to `span`, so from the caller's standpoint `span` isn't particularly relevant (as opposed to the API signatures where `span` is returned).

2. I thought it would be nice to keep the name similar to `dataWithBytes`, so it reads familiar.

That said, I am not feeling strongly and open to any name you suggest.


If you’re adding this, you’d probably also want a mutable variant (see above and below as well).

I don't mind doing that in a follow-up (as this semi-automated CL is already large).

Looking for feedback whether or not this patch is worth pursuing, and if yes what the names should be.

Open in Gerrit

Related details

Attention is currently required from:
  • Lei Zhang
  • Mark Mentovai
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: Ia8ce388928716670b7daf1c0bc49fba9f23caf91
Gerrit-Change-Number: 7560135
Gerrit-PatchSet: 10
Gerrit-Owner: Mikel Astiz <mas...@chromium.org>
Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
Gerrit-Reviewer: Mikel Astiz <mas...@chromium.org>
Gerrit-CC: (Julie)Jeongeun Kim <je_jul...@chromium.org>
Gerrit-CC: Akihiro Ota <akihi...@chromium.org>
Gerrit-CC: Avi Drissman <a...@chromium.org>
Gerrit-CC: Mark Mentovai <ma...@chromium.org>
Gerrit-Attention: Lei Zhang <the...@chromium.org>
Gerrit-Attention: Mark Mentovai <ma...@chromium.org>
Gerrit-Comment-Date: Thu, 12 Feb 2026 16:27:44 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Lei Zhang <the...@chromium.org>
Comment-In-Reply-To: Mark Mentovai <ma...@chromium.org>
Comment-In-Reply-To: Mikel Astiz <mas...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Mark Mentovai (Gerrit)

unread,
Feb 12, 2026, 5:08:16 PM (9 days ago) Feb 12
to Mikel Astiz, Avi Drissman, (Julie)Jeongeun Kim, AyeAye, Lei Zhang, Chromium LUCI CQ, chromium...@chromium.org, christia...@chromium.org, abigailbk...@google.com, extension...@chromium.org, ios-revie...@chromium.org, francisjp...@google.com, ios-web-view...@google.com, kyungjunle...@google.com, niharm...@google.com, omnibox-...@chromium.org, dtraino...@chromium.org, net-r...@chromium.org, jdonnel...@chromium.org, mattreyno...@chromium.org, chromium-a...@chromium.org, yuzo+...@chromium.org, marq+...@chromium.org, browser-comp...@chromium.org, filesapp...@chromium.org, ananyasee...@google.com, rkgibso...@chromium.org, nektar...@chromium.org, dtseng...@chromium.org, josiah...@chromium.org, feature-me...@chromium.org, aixba+wat...@chromium.org, dcheng+c...@chromium.org, derinel+wat...@google.com, dibyapal+wa...@chromium.org, dmurph+watc...@chromium.org, ios-rev...@chromium.org, ios-r...@chromium.org, japhet+...@chromium.org, kuragin+web-ap...@chromium.org, loyso...@chromium.org, mac-r...@chromium.org, mek+w...@chromium.org, mgiuca...@chromium.org, philli...@chromium.org, rsesek...@chromium.org, webap...@microsoft.com, webauthn...@chromium.org, zelin+watch-we...@chromium.org
Attention needed from Lei Zhang and Mikel Astiz

Mark Mentovai added 1 comment

File base/apple/foundation_util.h
Mark Mentovai

Looking for feedback whether or not this patch is worth pursuing, and if yes what the names should be.

I don’t know who you’re asking. I gave you my feedback.

Open in Gerrit

Related details

Attention is currently required from:
  • Lei Zhang
  • Mikel Astiz
Gerrit-Attention: Mikel Astiz <mas...@chromium.org>
Gerrit-Comment-Date: Thu, 12 Feb 2026 22:08:12 +0000
satisfied_requirement
unsatisfied_requirement
open
diffy

Mikel Astiz (Gerrit)

unread,
Feb 13, 2026, 5:52:15 AM (8 days ago) Feb 13
to Tom Sepez, Avi Drissman, (Julie)Jeongeun Kim, AyeAye, Mark Mentovai, Lei Zhang, Chromium LUCI CQ, chromium...@chromium.org, christia...@chromium.org, abigailbk...@google.com, extension...@chromium.org, ios-revie...@chromium.org, francisjp...@google.com, ios-web-view...@google.com, kyungjunle...@google.com, niharm...@google.com, omnibox-...@chromium.org, dtraino...@chromium.org, net-r...@chromium.org, jdonnel...@chromium.org, mattreyno...@chromium.org, chromium-a...@chromium.org, yuzo+...@chromium.org, marq+...@chromium.org, browser-comp...@chromium.org, filesapp...@chromium.org, ananyasee...@google.com, rkgibso...@chromium.org, nektar...@chromium.org, dtseng...@chromium.org, josiah...@chromium.org, feature-me...@chromium.org, aixba+wat...@chromium.org, dcheng+c...@chromium.org, derinel+wat...@google.com, dibyapal+wa...@chromium.org, dmurph+watc...@chromium.org, ios-rev...@chromium.org, ios-r...@chromium.org, japhet+...@chromium.org, kuragin+web-ap...@chromium.org, loyso...@chromium.org, mac-r...@chromium.org, mek+w...@chromium.org, mgiuca...@chromium.org, philli...@chromium.org, rsesek...@chromium.org, webap...@microsoft.com, webauthn...@chromium.org, zelin+watch-we...@chromium.org
Attention needed from Tom Sepez

Mikel Astiz added 1 comment

File base/apple/foundation_util.h
Mikel Astiz

Looking for feedback whether or not this patch is worth pursuing, and if yes what the names should be.

I don’t know who you’re asking.

Yeah, sorry, I honestly don't know who I should be asking or what the decision process is.

I gave you my feedback.

What I understood so far:
1. The benefits of the function appear questionable, because "there’s nothing compile-time UNSAFE about this operation that demands a wrapper" --> from this PoV it seems like you're not very keen on introducing this function.

2. We should add "span" to the name for consistency with other functions --> I made a counter argument about this (but not feeling strongly). It would be nice to hear your opinion about this, but also moot if the function shouldn't be introduced to begin with so let's clarify that first.

@tse...@chromium.org as the assignee for the linked bug (which I thought was appropriate): do you have an opinion about point 1 above? There's a handful of `reinterpret_cast` and `sizeof` removed in this patch, but I don't know if this justifies the introduction of a helper function as Mark pointed out above. See also the parent patch which does the same for strings.

If there's no appetite for this, I am totally fine abandoning these two patches. What motivated my contribution is that the conversion is particularly annoying if you need to invoke a function that returns a span, e.g. `Pickle::AsBytes()`, which needs to be invoked twice or use a local variable.

Open in Gerrit

Related details

Attention is currently required from:
  • Tom Sepez
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: Ia8ce388928716670b7daf1c0bc49fba9f23caf91
Gerrit-Change-Number: 7560135
Gerrit-PatchSet: 10
Gerrit-Owner: Mikel Astiz <mas...@chromium.org>
Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
Gerrit-Reviewer: Mikel Astiz <mas...@chromium.org>
Gerrit-CC: (Julie)Jeongeun Kim <je_jul...@chromium.org>
Gerrit-CC: Akihiro Ota <akihi...@chromium.org>
Gerrit-CC: Avi Drissman <a...@chromium.org>
Gerrit-CC: Mark Mentovai <ma...@chromium.org>
Gerrit-CC: Tom Sepez <tse...@chromium.org>
Gerrit-Attention: Tom Sepez <tse...@chromium.org>
Gerrit-Comment-Date: Fri, 13 Feb 2026 10:51:58 +0000
satisfied_requirement
unsatisfied_requirement
open
diffy

Mark Mentovai (Gerrit)

unread,
Feb 13, 2026, 11:31:36 AM (8 days ago) Feb 13
to Mikel Astiz, Tom Sepez, Avi Drissman, (Julie)Jeongeun Kim, AyeAye, Lei Zhang, Chromium LUCI CQ, chromium...@chromium.org, christia...@chromium.org, abigailbk...@google.com, extension...@chromium.org, ios-revie...@chromium.org, francisjp...@google.com, ios-web-view...@google.com, kyungjunle...@google.com, niharm...@google.com, omnibox-...@chromium.org, dtraino...@chromium.org, net-r...@chromium.org, jdonnel...@chromium.org, mattreyno...@chromium.org, chromium-a...@chromium.org, yuzo+...@chromium.org, marq+...@chromium.org, browser-comp...@chromium.org, filesapp...@chromium.org, ananyasee...@google.com, rkgibso...@chromium.org, nektar...@chromium.org, dtseng...@chromium.org, josiah...@chromium.org, feature-me...@chromium.org, aixba+wat...@chromium.org, dcheng+c...@chromium.org, derinel+wat...@google.com, dibyapal+wa...@chromium.org, dmurph+watc...@chromium.org, ios-rev...@chromium.org, ios-r...@chromium.org, japhet+...@chromium.org, kuragin+web-ap...@chromium.org, loyso...@chromium.org, mac-r...@chromium.org, mek+w...@chromium.org, mgiuca...@chromium.org, philli...@chromium.org, rsesek...@chromium.org, webap...@microsoft.com, webauthn...@chromium.org, zelin+watch-we...@chromium.org
Attention needed from Mikel Astiz and Tom Sepez

Mark Mentovai added 1 comment

File base/apple/foundation_util.h

I’m lukewarm. There’s no strong reason to add it, but I’m not against it, either. If people like it because there’s an interface at this level to perform the inverse operation, that’s fine with me. I can absolutely see an argument in favor of doing this on that basis.

2. We should add "span" to the name for consistency with other functions --> I made a counter argument about this (but not feeling strongly). It would be nice to hear your opinion about this, but also moot if the function shouldn't be introduced to begin with so let's clarify that first.

If you do add it, it’s solely in service of point 1 above. If you have an interface at this level to perform the inverse of an operation that’s already there, they need to use common language. You might like “bytes” naming better, but that’s not relevant when the existing code uses “span” naming. In fact, I think I like “bytes” naming better too, but my opinion on this point is just as irrelevant when there’s an established practice already in place.

If you felt strongly enough about the naming, you’d need to rename the existing uses too. I’m also lukewarm about this, but if you wanted to do it, it’s also fine with me.

“Handle mutable” is similar. The existing interface already handles immutable and mutable variants. If you’re adding to that existing body of work, you need to play by the rules that it’s already established. I don’t really care if you do it in one change or two, but I’d want to at least review them both at the same time, because a systematic problem that arises in one might have an impact on the other. At that point, you’re bumping up against merge conflict territory anyway, so you might as well load the work up into a single change. But I wouldn’t insist. If you like it better as two simultaneous changes and don’t mind merge toil, that’s fine.

@tse...@chromium.org as the assignee for the linked bug (which I thought was appropriate): do you have an opinion about point 1 above? There's a handful of `reinterpret_cast` and `sizeof` removed in this patch, but I don't know if this justifies the introduction of a helper function as Mark pointed out above. See also the parent patch which does the same for strings.

If there's no appetite for this, I am totally fine abandoning these two patches. What motivated my contribution is that the conversion is particularly annoying if you need to invoke a function that returns a span, e.g. `Pickle::AsBytes()`, which needs to be invoked twice or use a local variable.

I also asked @a...@chromium.org for his opinion. He also uses and works with this code regularly.

Open in Gerrit

Related details

Attention is currently required from:
  • Mikel Astiz
  • Tom Sepez
Gerrit-Attention: Mikel Astiz <mas...@chromium.org>
Gerrit-Comment-Date: Fri, 13 Feb 2026 16:31:31 +0000
satisfied_requirement
unsatisfied_requirement
open
diffy

Avi Drissman (Gerrit)

unread,
Feb 13, 2026, 1:53:44 PM (8 days ago) Feb 13
to Mikel Astiz, Tom Sepez, Avi Drissman, (Julie)Jeongeun Kim, AyeAye, Mark Mentovai, Lei Zhang, Chromium LUCI CQ, chromium...@chromium.org, christia...@chromium.org, abigailbk...@google.com, extension...@chromium.org, ios-revie...@chromium.org, francisjp...@google.com, ios-web-view...@google.com, kyungjunle...@google.com, niharm...@google.com, omnibox-...@chromium.org, dtraino...@chromium.org, net-r...@chromium.org, jdonnel...@chromium.org, mattreyno...@chromium.org, chromium-a...@chromium.org, yuzo+...@chromium.org, marq+...@chromium.org, browser-comp...@chromium.org, filesapp...@chromium.org, ananyasee...@google.com, rkgibso...@chromium.org, nektar...@chromium.org, dtseng...@chromium.org, josiah...@chromium.org, feature-me...@chromium.org, aixba+wat...@chromium.org, dcheng+c...@chromium.org, derinel+wat...@google.com, dibyapal+wa...@chromium.org, dmurph+watc...@chromium.org, ios-rev...@chromium.org, ios-r...@chromium.org, japhet+...@chromium.org, kuragin+web-ap...@chromium.org, loyso...@chromium.org, mac-r...@chromium.org, mek+w...@chromium.org, mgiuca...@chromium.org, philli...@chromium.org, rsesek...@chromium.org, webap...@microsoft.com, webauthn...@chromium.org, zelin+watch-we...@chromium.org
Attention needed from Mikel Astiz and Tom Sepez

Avi Drissman added 1 comment

File base/apple/foundation_util.h
Avi Drissman

I find it difficult to find enthusiasm for this change.

This replaces a single message send with a one-liner wrapper function. The convenience factory method `+[NSData dataWithBytes:length:]` is core API that folks that use Foundation are already very familiar with, and this change now expects them to switch to using a wrapper that they wouldn’t necessarily expect to exist.

We have wrappers that are one-liner-for-one-liner replacements (`(__bridge <<type>>)` vs `base::apple::CFToNSPtrCast<>`). However, for those there is some additional advantage gained by using them, whether doing additional type-checking or centralizing unsafe behavior, but I don’t see the advantage in this case.

Gerrit-Comment-Date: Fri, 13 Feb 2026 18:53:39 +0000
satisfied_requirement
unsatisfied_requirement
open
diffy

Mikel Astiz (Gerrit)

unread,
Feb 17, 2026, 5:20:49 AM (4 days ago) Feb 17
to Tom Sepez, Avi Drissman, (Julie)Jeongeun Kim, AyeAye, Mark Mentovai, Lei Zhang, Chromium LUCI CQ, chromium...@chromium.org, christia...@chromium.org, abigailbk...@google.com, extension...@chromium.org, ios-revie...@chromium.org, francisjp...@google.com, ios-web-view...@google.com, kyungjunle...@google.com, niharm...@google.com, omnibox-...@chromium.org, dtraino...@chromium.org, net-r...@chromium.org, jdonnel...@chromium.org, mattreyno...@chromium.org, chromium-a...@chromium.org, yuzo+...@chromium.org, marq+...@chromium.org, browser-comp...@chromium.org, filesapp...@chromium.org, ananyasee...@google.com, rkgibso...@chromium.org, nektar...@chromium.org, dtseng...@chromium.org, josiah...@chromium.org, feature-me...@chromium.org, aixba+wat...@chromium.org, dcheng+c...@chromium.org, derinel+wat...@google.com, dibyapal+wa...@chromium.org, dmurph+watc...@chromium.org, ios-rev...@chromium.org, ios-r...@chromium.org, japhet+...@chromium.org, kuragin+web-ap...@chromium.org, loyso...@chromium.org, mac-r...@chromium.org, mek+w...@chromium.org, mgiuca...@chromium.org, philli...@chromium.org, rsesek...@chromium.org, webap...@microsoft.com, webauthn...@chromium.org, zelin+watch-we...@chromium.org
Attention needed from Avi Drissman and Tom Sepez

Mikel Astiz added 1 comment

File base/apple/foundation_util.h
Mikel Astiz

Thanks Avi, that's reasonable.

One question though regarding unsafe behavior: we are often required to annotate with `UNSAFE_BUFFERS` when dealing with pointer/size pairs. I'm not sure what the exact criteria are, but `base::span_from_ref()` for example internally uses `UNSAFE_BUFFERS` when constructing a span. It strikes me as suspicious that `dataWithBytes` is considered safer:

```
NSData* data = [NSData dataWithBytes:buffer length:sizeof(buffer)]; // All good.
span<const uint8_t> span = NSDataToSpan(data); // All good.
span<const uint8_t> span2(buffer, sizeof(buffer)); // error: function introduces unsafe buffer manipulation [-Werror,-Wunsafe-buffer-usage]
```

Should this affect the fate of this patch? Or would it for example only make sense in combination with `UNSAFE_BUFFERS` being enforced for direct calls to `dataWithBytes`?

Again, to be clear, I don't want to make a strong case for introducing these APIs. Just making sure it is fully thought through, now that there's attention from several owners.

Open in Gerrit

Related details

Attention is currently required from:
  • Avi Drissman
  • Tom Sepez
Gerrit-Attention: Avi Drissman <a...@chromium.org>
Gerrit-Comment-Date: Tue, 17 Feb 2026 10:20:31 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Lei Zhang <the...@chromium.org>
Comment-In-Reply-To: Mark Mentovai <ma...@chromium.org>
Comment-In-Reply-To: Avi Drissman <a...@chromium.org>
Comment-In-Reply-To: Mikel Astiz <mas...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Avi Drissman (Gerrit)

unread,
Feb 17, 2026, 11:38:12 AM (4 days ago) Feb 17
to Mikel Astiz, Tom Sepez, Avi Drissman, (Julie)Jeongeun Kim, AyeAye, Mark Mentovai, Lei Zhang, Chromium LUCI CQ, chromium...@chromium.org, christia...@chromium.org, abigailbk...@google.com, extension...@chromium.org, ios-revie...@chromium.org, francisjp...@google.com, ios-web-view...@google.com, kyungjunle...@google.com, niharm...@google.com, omnibox-...@chromium.org, dtraino...@chromium.org, net-r...@chromium.org, jdonnel...@chromium.org, mattreyno...@chromium.org, chromium-a...@chromium.org, yuzo+...@chromium.org, marq+...@chromium.org, browser-comp...@chromium.org, filesapp...@chromium.org, ananyasee...@google.com, rkgibso...@chromium.org, nektar...@chromium.org, dtseng...@chromium.org, josiah...@chromium.org, feature-me...@chromium.org, aixba+wat...@chromium.org, dcheng+c...@chromium.org, derinel+wat...@google.com, dibyapal+wa...@chromium.org, dmurph+watc...@chromium.org, ios-rev...@chromium.org, ios-r...@chromium.org, japhet+...@chromium.org, kuragin+web-ap...@chromium.org, loyso...@chromium.org, mac-r...@chromium.org, mek+w...@chromium.org, mgiuca...@chromium.org, philli...@chromium.org, rsesek...@chromium.org, webap...@microsoft.com, webauthn...@chromium.org, zelin+watch-we...@chromium.org
Attention needed from Mikel Astiz and Tom Sepez

Avi Drissman added 1 comment

File base/apple/foundation_util.h
Avi Drissman

I am in agreement that `+[NSData dataWithBytes:length:]` is not safe. But this is at a platform API boundary, so the virality of spanification has to stop there.

Have we taken action at other platform API boundaries, and if so, is there precedent to refer to?

Open in Gerrit

Related details

Attention is currently required from:
  • Mikel Astiz
  • Tom Sepez
Gerrit-Attention: Mikel Astiz <mas...@chromium.org>
Gerrit-Comment-Date: Tue, 17 Feb 2026 16:38:06 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Lei Zhang <the...@chromium.org>
Comment-In-Reply-To: Mark Mentovai <ma...@chromium.org>
Comment-In-Reply-To: Mikel Astiz <mas...@chromium.org>
Comment-In-Reply-To: Avi Drissman <a...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Tom Sepez (Gerrit)

unread,
Feb 20, 2026, 1:29:37 PM (yesterday) Feb 20
to Mikel Astiz, Avi Drissman, (Julie)Jeongeun Kim, AyeAye, Mark Mentovai, Lei Zhang, Chromium LUCI CQ, chromium...@chromium.org, christia...@chromium.org, abigailbk...@google.com, extension...@chromium.org, ios-revie...@chromium.org, francisjp...@google.com, ios-web-view...@google.com, kyungjunle...@google.com, niharm...@google.com, omnibox-...@chromium.org, dtraino...@chromium.org, net-r...@chromium.org, jdonnel...@chromium.org, mattreyno...@chromium.org, chromium-a...@chromium.org, yuzo+...@chromium.org, marq+...@chromium.org, browser-comp...@chromium.org, filesapp...@chromium.org, ananyasee...@google.com, rkgibso...@chromium.org, nektar...@chromium.org, dtseng...@chromium.org, josiah...@chromium.org, feature-me...@chromium.org, aixba+wat...@chromium.org, dcheng+c...@chromium.org, derinel+wat...@google.com, dibyapal+wa...@chromium.org, dmurph+watc...@chromium.org, ios-rev...@chromium.org, ios-r...@chromium.org, japhet+...@chromium.org, kuragin+web-ap...@chromium.org, loyso...@chromium.org, mac-r...@chromium.org, mek+w...@chromium.org, mgiuca...@chromium.org, philli...@chromium.org, rsesek...@chromium.org, webap...@microsoft.com, webauthn...@chromium.org, zelin+watch-we...@chromium.org
Attention needed from Mikel Astiz

Tom Sepez added 1 comment

File base/apple/foundation_util.h
Tom Sepez

Other platforms? No, but other platforms don't have a platform-specific representation of owned ptr/length pairs -- just discrete arguments to system calls, say. So you're on our own here. Are there APIs on Mac that take a NSData instead of a pointer and length? If so, then this seems reasonable.

Open in Gerrit

Related details

Attention is currently required from:
  • Mikel Astiz
Gerrit-Attention: Mikel Astiz <mas...@chromium.org>
Gerrit-Comment-Date: Fri, 20 Feb 2026 18:29:31 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Lei Zhang <the...@chromium.org>
Comment-In-Reply-To: Mark Mentovai <ma...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Avi Drissman (Gerrit)

unread,
Feb 20, 2026, 1:57:51 PM (yesterday) Feb 20
to Mikel Astiz, Tom Sepez, Avi Drissman, (Julie)Jeongeun Kim, AyeAye, Mark Mentovai, Lei Zhang, Chromium LUCI CQ, chromium...@chromium.org, christia...@chromium.org, abigailbk...@google.com, extension...@chromium.org, ios-revie...@chromium.org, francisjp...@google.com, ios-web-view...@google.com, kyungjunle...@google.com, niharm...@google.com, omnibox-...@chromium.org, dtraino...@chromium.org, net-r...@chromium.org, jdonnel...@chromium.org, mattreyno...@chromium.org, chromium-a...@chromium.org, yuzo+...@chromium.org, marq+...@chromium.org, browser-comp...@chromium.org, filesapp...@chromium.org, ananyasee...@google.com, rkgibso...@chromium.org, nektar...@chromium.org, dtseng...@chromium.org, josiah...@chromium.org, feature-me...@chromium.org, aixba+wat...@chromium.org, dcheng+c...@chromium.org, derinel+wat...@google.com, dibyapal+wa...@chromium.org, dmurph+watc...@chromium.org, ios-rev...@chromium.org, ios-r...@chromium.org, japhet+...@chromium.org, kuragin+web-ap...@chromium.org, loyso...@chromium.org, mac-r...@chromium.org, mek+w...@chromium.org, mgiuca...@chromium.org, philli...@chromium.org, rsesek...@chromium.org, webap...@microsoft.com, webauthn...@chromium.org, zelin+watch-we...@chromium.org
Attention needed from Mikel Astiz

Avi Drissman added 1 comment

File base/apple/foundation_util.h
Avi Drissman

Most every API on the Mac that requires “a bunch of bytes” uses `NSData`. It’s the creation of the `NSData` itself that requires pointer/length.

Gerrit-Comment-Date: Fri, 20 Feb 2026 18:57:45 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Lei Zhang <the...@chromium.org>
Comment-In-Reply-To: Mark Mentovai <ma...@chromium.org>
Comment-In-Reply-To: Tom Sepez <tse...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Tom Sepez (Gerrit)

unread,
Feb 20, 2026, 7:49:00 PM (18 hours ago) Feb 20
to Mikel Astiz, Avi Drissman, (Julie)Jeongeun Kim, AyeAye, Mark Mentovai, Lei Zhang, Chromium LUCI CQ, chromium...@chromium.org, christia...@chromium.org, abigailbk...@google.com, extension...@chromium.org, ios-revie...@chromium.org, francisjp...@google.com, ios-web-view...@google.com, kyungjunle...@google.com, niharm...@google.com, omnibox-...@chromium.org, dtraino...@chromium.org, net-r...@chromium.org, jdonnel...@chromium.org, mattreyno...@chromium.org, chromium-a...@chromium.org, yuzo+...@chromium.org, marq+...@chromium.org, browser-comp...@chromium.org, filesapp...@chromium.org, ananyasee...@google.com, rkgibso...@chromium.org, nektar...@chromium.org, dtseng...@chromium.org, josiah...@chromium.org, feature-me...@chromium.org, aixba+wat...@chromium.org, dcheng+c...@chromium.org, derinel+wat...@google.com, dibyapal+wa...@chromium.org, dmurph+watc...@chromium.org, ios-rev...@chromium.org, ios-r...@chromium.org, japhet+...@chromium.org, kuragin+web-ap...@chromium.org, loyso...@chromium.org, mac-r...@chromium.org, mek+w...@chromium.org, mgiuca...@chromium.org, philli...@chromium.org, rsesek...@chromium.org, webap...@microsoft.com, webauthn...@chromium.org, zelin+watch-we...@chromium.org
Attention needed from Mikel Astiz

Tom Sepez added 1 comment

File base/apple/foundation_util.h
Tom Sepez
So where I might imagine this as being useful is to write
`NSDataWithBytes(data.subspan(10, 20))` instead of `[NSData dataWithBytes:data.data() + 10, length:20]` or
```
auto sub_data = data.subspan(10, 20);
[NSData dataWithBytes:data.sub_data() length:sub_data.size()];
```
Gerrit-Comment-Date: Sat, 21 Feb 2026 00:48:54 +0000
satisfied_requirement
unsatisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages