refactor: simplify DiscardEligibilityPolicy::CanDiscard [chromium/src : main]

1 view
Skip to first unread message

Shin Kawamura (Gerrit)

unread,
May 29, 2026, 5:20:17 AMMay 29
to android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, performance-m...@chromium.org, chrome-gr...@chromium.org

Shin Kawamura added 2 comments

File chrome/browser/performance_manager/policies/discard_eligibility_policy.cc
Line 22, Patchset 5 (Latest):#endif
#if !BUILDFLAG(IS_ANDROID)
Shin Kawamura . unresolved

This can be "else"?

File chrome/browser/performance_manager/policies/page_discarding_helper.h
Line 88, Patchset 5 (Latest): bool ignore_recent_visibility = false);
Shin Kawamura . unresolved

The default should be `true` for backward compatibility.

Open in Gerrit

Related details

Attention set is empty
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: If7650a9f248135b07b88a74e917c3fc8c4dfe670
Gerrit-Change-Number: 7884754
Gerrit-PatchSet: 5
Gerrit-Owner: Shin Kawamura <kaw...@google.com>
Gerrit-Reviewer: Shin Kawamura <kaw...@google.com>
Gerrit-Comment-Date: Fri, 29 May 2026 09:19:51 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Shin Kawamura (Gerrit)

unread,
May 29, 2026, 5:46:49 AMMay 29
to android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, performance-m...@chromium.org, chrome-gr...@chromium.org

Shin Kawamura voted and added 2 comments

Votes added by Shin Kawamura

Commit-Queue+1

2 comments

File chrome/browser/performance_manager/policies/discard_eligibility_policy.cc
Line 22, Patchset 5:#endif
#if !BUILDFLAG(IS_ANDROID)
Shin Kawamura . resolved

This can be "else"?

Shin Kawamura

Done

File chrome/browser/performance_manager/policies/page_discarding_helper.h
Line 88, Patchset 5: bool ignore_recent_visibility = false);
Shin Kawamura . resolved

The default should be `true` for backward compatibility.

Shin Kawamura

Done

Open in Gerrit

Related details

Attention set is empty
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: If7650a9f248135b07b88a74e917c3fc8c4dfe670
    Gerrit-Change-Number: 7884754
    Gerrit-PatchSet: 6
    Gerrit-Comment-Date: Fri, 29 May 2026 09:46:21 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Shin Kawamura <kaw...@google.com>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Patrick Monette (Gerrit)

    unread,
    Jun 1, 2026, 1:54:05 PMJun 1
    to Shin Kawamura, David Stevens, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, performance-m...@chromium.org, chrome-gr...@chromium.org
    Attention needed from Shin Kawamura

    Patrick Monette voted and added 2 comments

    Votes added by Patrick Monette

    Code-Review+1

    2 comments

    Patchset-level comments
    File-level comment, Patchset 11 (Latest):
    Patrick Monette . resolved

    lgtm

    File chrome/browser/performance_manager/policies/discard_eligibility_policy_unittest.cc
    Line 244, Patchset 11 (Latest): ExpectCanDiscardEligibleAllReasons(page_node(),
    Patrick Monette . unresolved

    pre-existing bug, but can you change this to use `new_page_node` please if that's not too much trouble?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Shin Kawamura
    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: If7650a9f248135b07b88a74e917c3fc8c4dfe670
    Gerrit-Change-Number: 7884754
    Gerrit-PatchSet: 11
    Gerrit-Owner: Shin Kawamura <kaw...@google.com>
    Gerrit-Reviewer: Patrick Monette <pmon...@chromium.org>
    Gerrit-Reviewer: Shin Kawamura <kaw...@google.com>
    Gerrit-CC: David Stevens <stev...@chromium.org>
    Gerrit-Attention: Shin Kawamura <kaw...@google.com>
    Gerrit-Comment-Date: Mon, 01 Jun 2026 17:53:50 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Patrick Monette (Gerrit)

    unread,
    Jun 1, 2026, 2:01:17 PMJun 1
    to Shin Kawamura, David Stevens, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, performance-m...@chromium.org, chrome-gr...@chromium.org
    Attention needed from Shin Kawamura

    Patrick Monette added 1 comment

    File chrome/browser/performance_manager/policies/discard_eligibility_policy.cc
    Line 189, Patchset 11 (Latest): if (base::android::device_info::is_desktop() ||
    Patrick Monette . unresolved

    The old logic did not check for base::android::device_info::is_desktop().

    Is that intended?

    Gerrit-Comment-Date: Mon, 01 Jun 2026 18:01:04 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Shin Kawamura (Gerrit)

    unread,
    Jun 4, 2026, 12:17:10 AMJun 4
    to Patrick Monette, David Stevens, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, performance-m...@chromium.org, chrome-gr...@chromium.org

    Shin Kawamura voted and added 2 comments

    Votes added by Shin Kawamura

    Commit-Queue+2

    2 comments

    File chrome/browser/performance_manager/policies/discard_eligibility_policy.cc
    Line 189, Patchset 11: if (base::android::device_info::is_desktop() ||
    Patrick Monette . resolved

    The old logic did not check for base::android::device_info::is_desktop().

    Is that intended?

    Shin Kawamura

    Yes. I changed it at https://crrev.com/c/7893747

    File chrome/browser/performance_manager/policies/discard_eligibility_policy_unittest.cc
    Line 244, Patchset 11: ExpectCanDiscardEligibleAllReasons(page_node(),
    Patrick Monette . resolved

    pre-existing bug, but can you change this to use `new_page_node` please if that's not too much trouble?

    Shin Kawamura

    I will do it in another CL.

    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: If7650a9f248135b07b88a74e917c3fc8c4dfe670
      Gerrit-Change-Number: 7884754
      Gerrit-PatchSet: 12
      Gerrit-Owner: Shin Kawamura <kaw...@google.com>
      Gerrit-Reviewer: Patrick Monette <pmon...@chromium.org>
      Gerrit-Reviewer: Shin Kawamura <kaw...@google.com>
      Gerrit-CC: David Stevens <stev...@chromium.org>
      Gerrit-Comment-Date: Thu, 04 Jun 2026 04:16:39 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      Comment-In-Reply-To: Patrick Monette <pmon...@chromium.org>
      satisfied_requirement
      open
      diffy

      Chromium LUCI CQ (Gerrit)

      unread,
      Jun 4, 2026, 1:09:43 AMJun 4
      to Shin Kawamura, Patrick Monette, David Stevens, android-bu...@system.gserviceaccount.com, performance-m...@chromium.org, chrome-gr...@chromium.org

      Chromium LUCI CQ submitted the change

      Unreviewed changes

      11 is the latest approved patch-set.
      No files were changed between the latest approved patch-set and the submitted one.

      Change information

      Commit message:
      refactor: simplify DiscardEligibilityPolicy::CanDiscard

      chrome://discards used CanDiscard() with
      kNonVisiblePagesUrgentProtectionTime and did not take
      kProtectRecentlyVisibleTabDuration into account.

      Refactor the main `CanDiscard` method to automatically resolve the
      background protection window. This encapsulates the implementation
      detail about kNonVisiblePagesUrgentProtectionTime selection and the
      Android-specific `ProtectRecentlyVisibleTab` duration logic within the
      policy itself. It also replaces the time-delta parameters with a simple
      boolean `ignore_recent_visibility` parameter.

      This introduced a new `CanDiscardWithCustomRecentVisibilityWindow`
      method in `DiscardEligibilityPolicy` to isolate usages that require
      custom protection windows, such as `CpuHealthTracker`.

      Align `PageDiscardingHelper` by replacing its
      `minimum_time_in_background` parameters with `ignore_recent_visibility`,
      simplifying its signature since all of its callers either use default or
      ignore durations.
      Bug: none
      Change-Id: If7650a9f248135b07b88a74e917c3fc8c4dfe670
      Reviewed-by: Patrick Monette <pmon...@chromium.org>
      Commit-Queue: Shin Kawamura <kaw...@google.com>
      Cr-Commit-Position: refs/heads/main@{#1641470}
      Files:
      • M chrome/browser/performance_manager/policies/discard_eligibility_policy.cc
      • M chrome/browser/performance_manager/policies/discard_eligibility_policy.h
      • M chrome/browser/performance_manager/policies/discard_eligibility_policy_browsertest.cc
      • M chrome/browser/performance_manager/policies/discard_eligibility_policy_unittest.cc
      • M chrome/browser/performance_manager/policies/page_discarding_helper.cc
      • M chrome/browser/performance_manager/policies/page_discarding_helper.h
      • M chrome/browser/performance_manager/policies/page_discarding_helper_browsertest.cc
      • M chrome/browser/performance_manager/policies/page_discarding_helper_unittest.cc
      • M chrome/browser/performance_manager/policies/process_rank_policy_android.cc
      • M chrome/browser/performance_manager/policies/termination_target_policy.cc
      • M chrome/browser/performance_manager/test_support/page_discarding_utils.cc
      • M chrome/browser/performance_manager/test_support/page_discarding_utils.h
      • M chrome/browser/performance_manager/user_tuning/cpu_health_tracker.cc
      • M chrome/browser/performance_manager/user_tuning/user_tuning_utils.cc
      • M chrome/browser/resource_coordinator/tab_manager.cc
      • M chrome/browser/resource_coordinator/tab_manager.h
      • M chrome/browser/resource_coordinator/tab_manager_browsertest.cc
      • M chrome/browser/resource_coordinator/test_lifecycle_unit.cc
      • M chrome/browser/resource_coordinator/utils.cc
      • M chrome/browser/resource_coordinator/utils.h
      Change size: L
      Delta: 20 files changed, 144 insertions(+), 121 deletions(-)
      Branch: refs/heads/main
      Submit Requirements:
      • requirement satisfiedCode-Review: +1 by Patrick Monette
      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: If7650a9f248135b07b88a74e917c3fc8c4dfe670
      Gerrit-Change-Number: 7884754
      Gerrit-PatchSet: 13
      Gerrit-Owner: Shin Kawamura <kaw...@google.com>
      Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
      Gerrit-Reviewer: Patrick Monette <pmon...@chromium.org>
      Gerrit-Reviewer: Shin Kawamura <kaw...@google.com>
      open
      diffy
      satisfied_requirement
      Reply all
      Reply to author
      Forward
      0 new messages