[Extensions] Port chrome.tabs.discard to desktop Android [chromium/src : main]

0 views
Skip to first unread message

Kelvin Jiang (Gerrit)

unread,
Feb 19, 2026, 10:27:25 PM (2 days ago) Feb 19
to Keigo Oka, Chromium LUCI CQ, chromium...@chromium.org, chrome-gr...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org
Attention needed from Keigo Oka

Kelvin Jiang voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Keigo Oka
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: Iff2dd41240b2254924722b5c87d92abe3def6866
Gerrit-Change-Number: 7594963
Gerrit-PatchSet: 3
Gerrit-Owner: Kelvin Jiang <kelvi...@chromium.org>
Gerrit-Reviewer: Keigo Oka <o...@chromium.org>
Gerrit-Reviewer: Kelvin Jiang <kelvi...@chromium.org>
Gerrit-Attention: Keigo Oka <o...@chromium.org>
Gerrit-Comment-Date: Fri, 20 Feb 2026 03:27:19 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

James Cook (Gerrit)

unread,
Feb 19, 2026, 10:48:08 PM (2 days ago) Feb 19
to Kelvin Jiang, Darryl James, Chromium LUCI CQ, chromium...@chromium.org, chrome-gr...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org
Attention needed from Darryl James and Kelvin Jiang

James Cook added 5 comments

Patchset-level comments
File-level comment, Patchset 3 (Latest):
James Cook . resolved

Overall shape looks good. A couple comments.

File chrome/browser/extensions/BUILD.gn
Line 639, Patchset 3 (Parent): "api/tabs/tabs_api_android.cc",
James Cook . unresolved

Hooray!

Line 656, Patchset 3 (Parent): "api/tabs/tabs_api_non_android.cc",
James Cook . unresolved

Hooray!

File chrome/browser/extensions/api/tabs/tabs_api.cc
Line 3688, Patchset 3 (Latest): int tab_index;
James Cook . unresolved

nit: initialize this

Line 3699, Patchset 3 (Latest): BrowserWindowInterface* browser_window =
James Cook . unresolved

nit: Check browser_window for null before using it. On ChromeOS it can be null for unusual window types. See https://chromium-review.googlesource.com/c/chromium/src/+/7596693

Open in Gerrit

Related details

Attention is currently required from:
  • Darryl James
  • Kelvin Jiang
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: Iff2dd41240b2254924722b5c87d92abe3def6866
    Gerrit-Change-Number: 7594963
    Gerrit-PatchSet: 3
    Gerrit-Owner: Kelvin Jiang <kelvi...@chromium.org>
    Gerrit-Reviewer: Darryl James <dlj...@chromium.org>
    Gerrit-Reviewer: James Cook <jame...@chromium.org>
    Gerrit-Reviewer: Kelvin Jiang <kelvi...@chromium.org>
    Gerrit-Attention: Kelvin Jiang <kelvi...@chromium.org>
    Gerrit-Attention: Darryl James <dlj...@chromium.org>
    Gerrit-Comment-Date: Fri, 20 Feb 2026 03:47:57 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Kelvin Jiang (Gerrit)

    unread,
    Feb 19, 2026, 11:28:45 PM (2 days ago) Feb 19
    to Darryl James, James Cook, Chromium LUCI CQ, chromium...@chromium.org, chrome-gr...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org
    Attention needed from Darryl James and James Cook

    Kelvin Jiang voted and added 5 comments

    Votes added by Kelvin Jiang

    Commit-Queue+1

    5 comments

    Patchset-level comments
    File-level comment, Patchset 4 (Latest):
    Kelvin Jiang . resolved

    That... was an interesting test flake

    File chrome/browser/extensions/BUILD.gn
    Line 639, Patchset 3 (Parent): "api/tabs/tabs_api_android.cc",
    James Cook . resolved

    Hooray!

    Kelvin Jiang

    Acknowledged

    Line 656, Patchset 3 (Parent): "api/tabs/tabs_api_non_android.cc",
    James Cook . resolved

    Hooray!

    Kelvin Jiang

    Acknowledged

    File chrome/browser/extensions/api/tabs/tabs_api.cc
    Line 3688, Patchset 3: int tab_index;
    James Cook . resolved

    nit: initialize this

    Kelvin Jiang

    Done

    Line 3699, Patchset 3: BrowserWindowInterface* browser_window =
    James Cook . resolved

    nit: Check browser_window for null before using it. On ChromeOS it can be null for unusual window types. See https://chromium-review.googlesource.com/c/chromium/src/+/7596693

    Kelvin Jiang

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Darryl James
    • James Cook
    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: Iff2dd41240b2254924722b5c87d92abe3def6866
      Gerrit-Change-Number: 7594963
      Gerrit-PatchSet: 4
      Gerrit-Owner: Kelvin Jiang <kelvi...@chromium.org>
      Gerrit-Reviewer: Darryl James <dlj...@chromium.org>
      Gerrit-Reviewer: James Cook <jame...@chromium.org>
      Gerrit-Reviewer: Kelvin Jiang <kelvi...@chromium.org>
      Gerrit-Attention: James Cook <jame...@chromium.org>
      Gerrit-Attention: Darryl James <dlj...@chromium.org>
      Gerrit-Comment-Date: Fri, 20 Feb 2026 04:28:37 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      Comment-In-Reply-To: James Cook <jame...@chromium.org>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      James Cook (Gerrit)

      unread,
      Feb 20, 2026, 12:50:56 PM (12 hours ago) Feb 20
      to Kelvin Jiang, Darryl James, Chromium LUCI CQ, chromium...@chromium.org, chrome-gr...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org
      Attention needed from Darryl James and Kelvin Jiang

      James Cook voted and added 2 comments

      Votes added by James Cook

      Code-Review+1

      2 comments

      Patchset-level comments
      James Cook . resolved

      LGTM

      File chrome/browser/extensions/api/tabs/tabs_api.cc
      Line 3705, Patchset 4 (Latest): TabListInterface* tab_list = TabListInterface::From(browser_window);
      James Cook . unresolved

      Sorry I didn't notice before... I wonder if we need to check tab_list for null as well. WDYT?

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Darryl James
      • Kelvin Jiang
      Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not 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: Iff2dd41240b2254924722b5c87d92abe3def6866
        Gerrit-Change-Number: 7594963
        Gerrit-PatchSet: 4
        Gerrit-Owner: Kelvin Jiang <kelvi...@chromium.org>
        Gerrit-Reviewer: Darryl James <dlj...@chromium.org>
        Gerrit-Reviewer: James Cook <jame...@chromium.org>
        Gerrit-Reviewer: Kelvin Jiang <kelvi...@chromium.org>
        Gerrit-Attention: Kelvin Jiang <kelvi...@chromium.org>
        Gerrit-Attention: Darryl James <dlj...@chromium.org>
        Gerrit-Comment-Date: Fri, 20 Feb 2026 17:50:49 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: Yes
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Darryl James (Gerrit)

        unread,
        Feb 20, 2026, 2:44:57 PM (10 hours ago) Feb 20
        to Kelvin Jiang, James Cook, Chromium LUCI CQ, chromium...@chromium.org, chrome-gr...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org
        Attention needed from Kelvin Jiang

        Darryl James added 2 comments

        File chrome/browser/extensions/extension_tab_util.cc
        Line 438, Patchset 4 (Latest): tab_object.discarded = contents->WasDiscarded();
        Darryl James . unresolved

        Is it right that ENABLE_EXTENSIONS is true for desktop Android? I have a feeling that desktop Android can take the top path as well.

        File chrome/browser/resource_coordinator/utils.cc
        Line 79, Patchset 4 (Latest): return performance_manager::policies::PageDiscardingHelper::GetFromGraph(
        graph)
        ->DiscardAPage(discard_reason, urgent_protection_time)
        .first_content_after_discard;
        Darryl James . unresolved

        What are your thoughts on splitting this call up to avoid nullptr dereferences?

        Ex:
        ```
        if (!GetFromGraph()) {
        return nullptr;
        }
        if (!DiscardAPage()) {
        return nullptr;
        }

        return first_content_after_discard;
        ```

        It could be the case that these will always return a value, in that case disregard this comment 👍

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Kelvin Jiang
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not 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: Iff2dd41240b2254924722b5c87d92abe3def6866
        Gerrit-Change-Number: 7594963
        Gerrit-PatchSet: 4
        Gerrit-Owner: Kelvin Jiang <kelvi...@chromium.org>
        Gerrit-Reviewer: Darryl James <dlj...@chromium.org>
        Gerrit-Reviewer: James Cook <jame...@chromium.org>
        Gerrit-Reviewer: Kelvin Jiang <kelvi...@chromium.org>
        Gerrit-Attention: Kelvin Jiang <kelvi...@chromium.org>
        Gerrit-Comment-Date: Fri, 20 Feb 2026 19:44:50 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        James Cook (Gerrit)

        unread,
        Feb 20, 2026, 2:59:42 PM (10 hours ago) Feb 20
        to Kelvin Jiang, Darryl James, Chromium LUCI CQ, chromium...@chromium.org, chrome-gr...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org
        Attention needed from Kelvin Jiang

        James Cook added 1 comment

        File chrome/browser/extensions/extension_tab_util.cc
        Line 438, Patchset 4 (Latest): tab_object.discarded = contents->WasDiscarded();
        Darryl James . unresolved

        Is it right that ENABLE_EXTENSIONS is true for desktop Android? I have a feeling that desktop Android can take the top path as well.

        James Cook

        Actually, ENABLE_EXTENSIONS is false for desktop Android. ENABLE_EXTENSIONS_CORE is true. I wonder if this block would be clearer if we switched to BUILDFLAG(IS_ANDROID), since it sounds like there might be long-term differences in discard behavior between Android and other platforms.

        Gerrit-Comment-Date: Fri, 20 Feb 2026 19:59:35 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: Darryl James <dlj...@chromium.org>
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Darryl James (Gerrit)

        unread,
        Feb 20, 2026, 4:15:09 PM (8 hours ago) Feb 20
        to Kelvin Jiang, James Cook, Chromium LUCI CQ, chromium...@chromium.org, chrome-gr...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org
        Attention needed from Kelvin Jiang

        Darryl James added 1 comment

        File chrome/browser/extensions/extension_tab_util.cc
        Line 438, Patchset 4 (Latest): tab_object.discarded = contents->WasDiscarded();
        Darryl James . unresolved

        Is it right that ENABLE_EXTENSIONS is true for desktop Android? I have a feeling that desktop Android can take the top path as well.

        James Cook

        Actually, ENABLE_EXTENSIONS is false for desktop Android. ENABLE_EXTENSIONS_CORE is true. I wonder if this block would be clearer if we switched to BUILDFLAG(IS_ANDROID), since it sounds like there might be long-term differences in discard behavior between Android and other platforms.

        Darryl James

        Thanks for the correction! I keep confusing the 2 flags with each other - my personal preference would be to use `IS_ANDROID` purely because I keep mixing the extensions flags up but that is entirely user error 😂

        Gerrit-Comment-Date: Fri, 20 Feb 2026 21:15:01 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: James Cook <jame...@chromium.org>
        Comment-In-Reply-To: Darryl James <dlj...@chromium.org>
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Kelvin Jiang (Gerrit)

        unread,
        Feb 20, 2026, 8:19:31 PM (4 hours ago) Feb 20
        to James Cook, Darryl James, Chromium LUCI CQ, chromium...@chromium.org, chrome-gr...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org
        Attention needed from Darryl James

        Kelvin Jiang voted and added 3 comments

        Votes added by Kelvin Jiang

        Commit-Queue+1

        3 comments

        File chrome/browser/extensions/api/tabs/tabs_api.cc
        Line 3705, Patchset 4: TabListInterface* tab_list = TabListInterface::From(browser_window);
        James Cook . resolved

        Sorry I didn't notice before... I wonder if we need to check tab_list for null as well. WDYT?

        Kelvin Jiang

        We should add a CHECK here since at this point we do have a valid browser window corresponding to the tab's ID

        File chrome/browser/extensions/extension_tab_util.cc
        Line 438, Patchset 4: tab_object.discarded = contents->WasDiscarded();
        Darryl James . resolved

        Is it right that ENABLE_EXTENSIONS is true for desktop Android? I have a feeling that desktop Android can take the top path as well.

        James Cook

        Actually, ENABLE_EXTENSIONS is false for desktop Android. ENABLE_EXTENSIONS_CORE is true. I wonder if this block would be clearer if we switched to BUILDFLAG(IS_ANDROID), since it sounds like there might be long-term differences in discard behavior between Android and other platforms.

        Darryl James

        Thanks for the correction! I keep confusing the 2 flags with each other - my personal preference would be to use `IS_ANDROID` purely because I keep mixing the extensions flags up but that is entirely user error 😂

        Kelvin Jiang

        Done

        File chrome/browser/resource_coordinator/utils.cc
        Line 79, Patchset 4: return performance_manager::policies::PageDiscardingHelper::GetFromGraph(

        graph)
        ->DiscardAPage(discard_reason, urgent_protection_time)
        .first_content_after_discard;
        Darryl James . resolved

        What are your thoughts on splitting this call up to avoid nullptr dereferences?

        Ex:
        ```
        if (!GetFromGraph()) {
        return nullptr;
        }
        if (!DiscardAPage()) {
        return nullptr;
        }

        return first_content_after_discard;
        ```

        It could be the case that these will always return a value, in that case disregard this comment 👍

        Kelvin Jiang

        Done for the page discarding helper: DiscardAPage always returns a struct value

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Darryl James
        Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement is not 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: Iff2dd41240b2254924722b5c87d92abe3def6866
          Gerrit-Change-Number: 7594963
          Gerrit-PatchSet: 5
          Gerrit-Owner: Kelvin Jiang <kelvi...@chromium.org>
          Gerrit-Reviewer: Darryl James <dlj...@chromium.org>
          Gerrit-Reviewer: James Cook <jame...@chromium.org>
          Gerrit-Reviewer: Kelvin Jiang <kelvi...@chromium.org>
          Gerrit-Attention: Darryl James <dlj...@chromium.org>
          Gerrit-Comment-Date: Sat, 21 Feb 2026 01:19:24 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: Yes
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy
          Reply all
          Reply to author
          Forward
          0 new messages