WTF: Represent encoding aliases as StringView [chromium/src : main]

0 views
Skip to first unread message

Kent Tamura (Gerrit)

unread,
Dec 15, 2025, 4:13:30 AM (yesterday) Dec 15
to Kent Tamura, Fredrik Söderquist, Chromium LUCI CQ, chromium...@chromium.org, blink-re...@chromium.org, blink-rev...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, jshin...@chromium.org, kinuko...@chromium.org, loading-rev...@chromium.org
Attention needed from Fredrik Söderquist

Kent Tamura voted and added 1 comment

Votes added by Kent Tamura

Auto-Submit+1

1 comment

Patchset-level comments
File-level comment, Patchset 6 (Latest):
Kent Tamura . resolved

fs@, would you review this please?

Open in Gerrit

Related details

Attention is currently required from:
  • Fredrik Söderquist
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement 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: I60d8ed6e564a74bfe08c04b1f59016ab273501a1
Gerrit-Change-Number: 7259694
Gerrit-PatchSet: 6
Gerrit-Owner: Kent Tamura <tk...@chromium.org>
Gerrit-Reviewer: Fredrik Söderquist <f...@opera.com>
Gerrit-Reviewer: Kent Tamura <tk...@chromium.org>
Gerrit-Attention: Fredrik Söderquist <f...@opera.com>
Gerrit-Comment-Date: Mon, 15 Dec 2025 09:13:00 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

AI Code Reviewer (Gerrit)

unread,
Dec 15, 2025, 4:16:59 AM (yesterday) Dec 15
to Kent Tamura, Fredrik Söderquist, Chromium LUCI CQ, chromium...@chromium.org, blink-re...@chromium.org, blink-rev...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, jshin...@chromium.org, kinuko...@chromium.org, loading-rev...@chromium.org
Attention needed from Fredrik Söderquist

AI Code Reviewer added 2 comments

File third_party/blink/renderer/platform/wtf/text/text_encoding_registry.cc
Line 123, Patchset 6 (Latest): if (alias.Find([](UChar ch) { return ch == ','; }) != kNotFound) {
AI Code Reviewer . unresolved

nit: Use 'alias.Find(',')' instead of a lambda for simplicity. (Blink Style Guide: Clarity and Conciseness)

To keep this interaction as brief and non-intrusive as possible, please consider responding with one of following options:
**Done** | **OK But Won't Fix**: reason | **Later**: b/<bug_id> | **Invalid:** reason


_This comment was generated by [Experimental Blink C++ Code Review Agent](http://go/blink-c++-code-review-agent)._
_AI reviews can sometimes be inaccurate; We appreciate your 🙏 feedback 🙏 to help us improve._
_[File a bug](http://go/blink-c++-code-review-agent-feedback) | [Provide feedback on chat](https://chat.google.com/room/AAQA0zhQHe0?cls=4) | [Opt-out](https://ganpati2.corp.google.com/group/peep-genai-blink-agent-optout.prod)_

Line 207, Patchset 6 (Latest): if (name.Find([](UChar ch) { return ch == '\0'; }) != kNotFound) {
AI Code Reviewer . unresolved

nit: Use 'name.Find('\0')' instead of a lambda for simplicity. (Blink Style Guide: Clarity and Conciseness)

To keep this interaction as brief and non-intrusive as possible, please consider responding with one of following options:
**Done** | **OK But Won't Fix**: reason | **Later**: b/<bug_id> | **Invalid:** reason


_This comment was generated by [Experimental Blink C++ Code Review Agent](http://go/blink-c++-code-review-agent)._
_AI reviews can sometimes be inaccurate; We appreciate your 🙏 feedback 🙏 to help us improve._
_[File a bug](http://go/blink-c++-code-review-agent-feedback) | [Provide feedback on chat](https://chat.google.com/room/AAQA0zhQHe0?cls=4) | [Opt-out](https://ganpati2.corp.google.com/group/peep-genai-blink-agent-optout.prod)_

Open in Gerrit

Related details

Attention is currently required from:
  • Fredrik Söderquist
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement 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: I60d8ed6e564a74bfe08c04b1f59016ab273501a1
    Gerrit-Change-Number: 7259694
    Gerrit-PatchSet: 6
    Gerrit-Owner: Kent Tamura <tk...@chromium.org>
    Gerrit-Reviewer: Fredrik Söderquist <f...@opera.com>
    Gerrit-Reviewer: Kent Tamura <tk...@chromium.org>
    Gerrit-CC: AI Code Reviewer <peep-gen...@system.gserviceaccount.com>
    Gerrit-Attention: Fredrik Söderquist <f...@opera.com>
    Gerrit-Comment-Date: Mon, 15 Dec 2025 09:16:55 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Fredrik Söderquist (Gerrit)

    unread,
    Dec 15, 2025, 5:09:00 AM (yesterday) Dec 15
    to Kent Tamura, AI Code Reviewer, Chromium LUCI CQ, chromium...@chromium.org, blink-re...@chromium.org, blink-rev...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, jshin...@chromium.org, kinuko...@chromium.org, loading-rev...@chromium.org
    Attention needed from Kent Tamura

    Fredrik Söderquist voted and added 6 comments

    Votes added by Fredrik Söderquist

    Code-Review+1

    6 comments

    Patchset-level comments
    Fredrik Söderquist . resolved

    LGTM % a few nits

    File third_party/blink/renderer/core/html/parser/text_resource_decoder.cc
    Line 51, Patchset 6 (Latest): return TextEncoding(StringView(base::as_bytes(base::span(encoding_name))));
    Fredrik Söderquist . unresolved
    ```suggestion
    return TextEncoding(StringView(base::as_byte_span(encoding_name)));
    ```
    File third_party/blink/renderer/modules/shared_storage/shared_storage_worklet_global_scope.cc
    Line 1221, Patchset 6 (Latest): StringView(base::as_bytes(base::span(response_head->charset)))),
    Fredrik Söderquist . unresolved
    ```suggestion
    StringView(base::as_byte_span(response_head->charset))),
    ```
    File third_party/blink/renderer/platform/wtf/text/text_encoding_registry.cc
    Line 123, Patchset 6 (Latest): if (alias.Find([](UChar ch) { return ch == ','; }) != kNotFound) {
    AI Code Reviewer . unresolved

    nit: Use 'alias.Find(',')' instead of a lambda for simplicity. (Blink Style Guide: Clarity and Conciseness)

    To keep this interaction as brief and non-intrusive as possible, please consider responding with one of following options:
    **Done** | **OK But Won't Fix**: reason | **Later**: b/<bug_id> | **Invalid:** reason


    _This comment was generated by [Experimental Blink C++ Code Review Agent](http://go/blink-c++-code-review-agent)._
    _AI reviews can sometimes be inaccurate; We appreciate your 🙏 feedback 🙏 to help us improve._
    _[File a bug](http://go/blink-c++-code-review-agent-feedback) | [Provide feedback on chat](https://chat.google.com/room/AAQA0zhQHe0?cls=4) | [Opt-out](https://ganpati2.corp.google.com/group/peep-genai-blink-agent-optout.prod)_

    Fredrik Söderquist

    +1

    Line 202, Patchset 6 (Latest): if (const auto* impl = name.SharedImpl()) {
    if (!impl->ContainsOnlyASCIIOrEmpty()) {
    return g_null_atom;
    }
    }
    Fredrik Söderquist . unresolved

    So, we're making the assumption here that if the StringView was not sourced from a String, it will already follow this restriction (since that how it used to work)? Shouldn't the same apply to the check for a `\0` then in that case? Anyway, might make sense to make a note about that.

    Line 207, Patchset 6 (Latest): if (name.Find([](UChar ch) { return ch == '\0'; }) != kNotFound) {
    AI Code Reviewer . unresolved

    nit: Use 'name.Find('\0')' instead of a lambda for simplicity. (Blink Style Guide: Clarity and Conciseness)

    To keep this interaction as brief and non-intrusive as possible, please consider responding with one of following options:
    **Done** | **OK But Won't Fix**: reason | **Later**: b/<bug_id> | **Invalid:** reason


    _This comment was generated by [Experimental Blink C++ Code Review Agent](http://go/blink-c++-code-review-agent)._
    _AI reviews can sometimes be inaccurate; We appreciate your 🙏 feedback 🙏 to help us improve._
    _[File a bug](http://go/blink-c++-code-review-agent-feedback) | [Provide feedback on chat](https://chat.google.com/room/AAQA0zhQHe0?cls=4) | [Opt-out](https://ganpati2.corp.google.com/group/peep-genai-blink-agent-optout.prod)_

    Fredrik Söderquist

    +1

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Kent Tamura
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement 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: I60d8ed6e564a74bfe08c04b1f59016ab273501a1
      Gerrit-Change-Number: 7259694
      Gerrit-PatchSet: 6
      Gerrit-Owner: Kent Tamura <tk...@chromium.org>
      Gerrit-Reviewer: Fredrik Söderquist <f...@opera.com>
      Gerrit-Reviewer: Kent Tamura <tk...@chromium.org>
      Gerrit-CC: AI Code Reviewer <peep-gen...@system.gserviceaccount.com>
      Gerrit-Attention: Kent Tamura <tk...@chromium.org>
      Gerrit-Comment-Date: Mon, 15 Dec 2025 10:08:38 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      Comment-In-Reply-To: AI Code Reviewer <peep-gen...@system.gserviceaccount.com>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Fredrik Söderquist (Gerrit)

      unread,
      Dec 15, 2025, 10:07:30 AM (yesterday) Dec 15
      to Kent Tamura, AI Code Reviewer, Chromium LUCI CQ, chromium...@chromium.org, blink-re...@chromium.org, blink-rev...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, jshin...@chromium.org, kinuko...@chromium.org, loading-rev...@chromium.org
      Attention needed from Kent Tamura

      Fredrik Söderquist added 2 comments

      File third_party/blink/renderer/platform/wtf/text/text_encoding_registry.cc
      Line 123, Patchset 6 (Latest): if (alias.Find([](UChar ch) { return ch == ','; }) != kNotFound) {
      AI Code Reviewer . resolved

      nit: Use 'alias.Find(',')' instead of a lambda for simplicity. (Blink Style Guide: Clarity and Conciseness)

      To keep this interaction as brief and non-intrusive as possible, please consider responding with one of following options:
      **Done** | **OK But Won't Fix**: reason | **Later**: b/<bug_id> | **Invalid:** reason


      _This comment was generated by [Experimental Blink C++ Code Review Agent](http://go/blink-c++-code-review-agent)._
      _AI reviews can sometimes be inaccurate; We appreciate your 🙏 feedback 🙏 to help us improve._
      _[File a bug](http://go/blink-c++-code-review-agent-feedback) | [Provide feedback on chat](https://chat.google.com/room/AAQA0zhQHe0?cls=4) | [Opt-out](https://ganpati2.corp.google.com/group/peep-genai-blink-agent-optout.prod)_

      Fredrik Söderquist

      +1

      Fredrik Söderquist

      I realized that these were bogus (`StringView` doesn't have any other variants of `Find()`)... (Maybe it would make sense to add though... we have two users now at least...)

      Line 207, Patchset 6 (Latest): if (name.Find([](UChar ch) { return ch == '\0'; }) != kNotFound) {
      AI Code Reviewer . resolved

      nit: Use 'name.Find('\0')' instead of a lambda for simplicity. (Blink Style Guide: Clarity and Conciseness)

      To keep this interaction as brief and non-intrusive as possible, please consider responding with one of following options:
      **Done** | **OK But Won't Fix**: reason | **Later**: b/<bug_id> | **Invalid:** reason


      _This comment was generated by [Experimental Blink C++ Code Review Agent](http://go/blink-c++-code-review-agent)._
      _AI reviews can sometimes be inaccurate; We appreciate your 🙏 feedback 🙏 to help us improve._
      _[File a bug](http://go/blink-c++-code-review-agent-feedback) | [Provide feedback on chat](https://chat.google.com/room/AAQA0zhQHe0?cls=4) | [Opt-out](https://ganpati2.corp.google.com/group/peep-genai-blink-agent-optout.prod)_

      Fredrik Söderquist

      +1

      Fredrik Söderquist

      Ditto here.

      Gerrit-Comment-Date: Mon, 15 Dec 2025 15:07:15 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: AI Code Reviewer <peep-gen...@system.gserviceaccount.com>
      Comment-In-Reply-To: Fredrik Söderquist <f...@opera.com>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Kent Tamura (Gerrit)

      unread,
      Dec 15, 2025, 7:12:41 PM (yesterday) Dec 15
      to Kent Tamura, Fredrik Söderquist, AI Code Reviewer, Chromium LUCI CQ, chromium...@chromium.org, blink-re...@chromium.org, blink-rev...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, jshin...@chromium.org, kinuko...@chromium.org, loading-rev...@chromium.org

      Kent Tamura voted and added 3 comments

      Votes added by Kent Tamura

      Auto-Submit+1
      Commit-Queue+2

      3 comments

      File third_party/blink/renderer/core/html/parser/text_resource_decoder.cc
      Line 51, Patchset 6: return TextEncoding(StringView(base::as_bytes(base::span(encoding_name))));
      Fredrik Söderquist . resolved
      ```suggestion
      return TextEncoding(StringView(base::as_byte_span(encoding_name)));
      ```
      Kent Tamura

      Done

      File third_party/blink/renderer/modules/shared_storage/shared_storage_worklet_global_scope.cc
      Line 1221, Patchset 6: StringView(base::as_bytes(base::span(response_head->charset)))),
      Fredrik Söderquist . resolved
      ```suggestion
      StringView(base::as_byte_span(response_head->charset))),
      ```
      Kent Tamura

      Done

      File third_party/blink/renderer/platform/wtf/text/text_encoding_registry.cc
      Line 202, Patchset 6: if (const auto* impl = name.SharedImpl()) {

      if (!impl->ContainsOnlyASCIIOrEmpty()) {
      return g_null_atom;
      }
      }
      Fredrik Söderquist . resolved

      So, we're making the assumption here that if the StringView was not sourced from a String, it will already follow this restriction (since that how it used to work)? Shouldn't the same apply to the check for a `\0` then in that case? Anyway, might make sense to make a note about that.

      Kent Tamura

      I added a comment about this optimization.

      Shouldn't the same apply to the check for a \0 then in that case? Anyway, might make sense to make a note about that.

      I removed the `\0` check.
      I think it made sense while the HashMap key was 0-terminated string, but now it's a String and it's not worth to pay O(N) cost.

      Open in Gerrit

      Related details

      Attention set is empty
      Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement satisfiedCode-Owners
        • requirement satisfiedCode-Review
        • requirement 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: I60d8ed6e564a74bfe08c04b1f59016ab273501a1
        Gerrit-Change-Number: 7259694
        Gerrit-PatchSet: 7
        Gerrit-Owner: Kent Tamura <tk...@chromium.org>
        Gerrit-Reviewer: Fredrik Söderquist <f...@opera.com>
        Gerrit-Reviewer: Kent Tamura <tk...@chromium.org>
        Gerrit-CC: AI Code Reviewer <peep-gen...@system.gserviceaccount.com>
        Gerrit-Comment-Date: Tue, 16 Dec 2025 00:11:57 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: Yes
        Comment-In-Reply-To: Fredrik Söderquist <f...@opera.com>
        satisfied_requirement
        open
        diffy

        Chromium LUCI CQ (Gerrit)

        unread,
        Dec 15, 2025, 7:15:17 PM (yesterday) Dec 15
        to Kent Tamura, Fredrik Söderquist, AI Code Reviewer, chromium...@chromium.org, blink-re...@chromium.org, blink-rev...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, jshin...@chromium.org, kinuko...@chromium.org, loading-rev...@chromium.org

        Chromium LUCI CQ submitted the change with unreviewed changes

        Unreviewed changes

        6 is the latest approved patch-set.
        The change was submitted with unreviewed changes in the following files:

        ```
        The name of the file: third_party/blink/renderer/platform/wtf/text/text_encoding_registry.cc
        Insertions: 4, Deletions: 3.

        The diff is too large to show. Please review the diff.
        ```
        ```
        The name of the file: third_party/blink/renderer/core/html/parser/text_resource_decoder.cc
        Insertions: 1, Deletions: 1.

        The diff is too large to show. Please review the diff.
        ```
        ```
        The name of the file: third_party/blink/renderer/modules/shared_storage/shared_storage_worklet_global_scope.cc
        Insertions: 1, Deletions: 2.

        The diff is too large to show. Please review the diff.
        ```

        Change information

        Commit message:
        WTF: Represent encoding aliases as StringView

        * Change the key type of TextEncodingNameMap from `const char*` to
        `String` because we don't use 0-terminated strings for aliases.

        * Unify two TextEncoding constructors into one, which takes a
        StringView

        * Unify two AtomicCanonicalTextEncodingName() overloads into one,
        which takes a StringView

        This CL removes 3 UNSAFE_TODO()s, and has no behavior changes.
        Bug: 451652367
        Change-Id: I60d8ed6e564a74bfe08c04b1f59016ab273501a1
        Auto-Submit: Kent Tamura <tk...@chromium.org>
        Reviewed-by: Fredrik Söderquist <f...@opera.com>
        Commit-Queue: Kent Tamura <tk...@chromium.org>
        Cr-Commit-Position: refs/heads/main@{#1559055}
        Files:
        • M third_party/blink/renderer/core/html/parser/text_resource_decoder.cc
        • M third_party/blink/renderer/modules/shared_storage/shared_storage_worklet_global_scope.cc
        • M third_party/blink/renderer/platform/wtf/text/text_encoding.cc
        • M third_party/blink/renderer/platform/wtf/text/text_encoding.h
        • M third_party/blink/renderer/platform/wtf/text/text_encoding_registry.cc
        • M third_party/blink/renderer/platform/wtf/text/text_encoding_registry.h
        Change size: M
        Delta: 6 files changed, 42 insertions(+), 63 deletions(-)
        Branch: refs/heads/main
        Submit Requirements:
        • requirement satisfiedCode-Review: +1 by Fredrik Söderquist
        Open in Gerrit
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: merged
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: I60d8ed6e564a74bfe08c04b1f59016ab273501a1
        Gerrit-Change-Number: 7259694
        Gerrit-PatchSet: 8
        Gerrit-Owner: Kent Tamura <tk...@chromium.org>
        Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
        Gerrit-Reviewer: Fredrik Söderquist <f...@opera.com>
        Gerrit-Reviewer: Kent Tamura <tk...@chromium.org>
        Gerrit-CC: AI Code Reviewer <peep-gen...@system.gserviceaccount.com>
        open
        diffy
        satisfied_requirement

        Fredrik Söderquist (Gerrit)

        unread,
        4:39 AM (18 hours ago) 4:39 AM
        to Chromium LUCI CQ, Kent Tamura, AI Code Reviewer, chromium...@chromium.org, blink-re...@chromium.org, blink-rev...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, jshin...@chromium.org, kinuko...@chromium.org, loading-rev...@chromium.org

        Fredrik Söderquist added 1 comment

        File third_party/blink/renderer/platform/wtf/text/text_encoding_registry.cc
        Line 202, Patchset 6: if (const auto* impl = name.SharedImpl()) {
        if (!impl->ContainsOnlyASCIIOrEmpty()) {
        return g_null_atom;
        }
        }
        Fredrik Söderquist . resolved

        So, we're making the assumption here that if the StringView was not sourced from a String, it will already follow this restriction (since that how it used to work)? Shouldn't the same apply to the check for a `\0` then in that case? Anyway, might make sense to make a note about that.

        Kent Tamura

        I added a comment about this optimization.

        Shouldn't the same apply to the check for a \0 then in that case? Anyway, might make sense to make a note about that.

        I removed the `\0` check.
        I think it made sense while the HashMap key was 0-terminated string, but now it's a String and it's not worth to pay O(N) cost.

        Fredrik Söderquist

        👍

        Open in Gerrit

        Related details

        Attention set is empty
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement satisfiedCode-Owners
        • requirement satisfiedCode-Review
        • requirement 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: I60d8ed6e564a74bfe08c04b1f59016ab273501a1
        Gerrit-Change-Number: 7259694
        Gerrit-PatchSet: 8
        Gerrit-Owner: Kent Tamura <tk...@chromium.org>
        Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
        Gerrit-Reviewer: Fredrik Söderquist <f...@opera.com>
        Gerrit-Reviewer: Kent Tamura <tk...@chromium.org>
        Gerrit-CC: AI Code Reviewer <peep-gen...@system.gserviceaccount.com>
        Gerrit-Comment-Date: Tue, 16 Dec 2025 09:38:54 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: Fredrik Söderquist <f...@opera.com>
        Comment-In-Reply-To: Kent Tamura <tk...@chromium.org>
        satisfied_requirement
        open
        diffy
        Reply all
        Reply to author
        Forward
        0 new messages